G
Guest
Doing the simple DropDown List binding using the method NextResult()
But its just not populating ..
what am i missing
Its populating the 3 DropDwonList but no Data?
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not IsPostBack Then
Dim sqlConnection As SqlConnection = New SqlConnection
sqlConnection.ConnectionString =
ConfigurationSettings.AppSettings("northwind")
sqlConnection.Open()
Dim sqlCommand As SqlCommand = New SqlCommand
sqlCommand.Connection = sqlConnection
sqlCommand.CommandText = "SELECT ProductName FROM
Products;SELECT CompanyName FROM Shippers;SELECT LastName FROM Employees"
Dim sqlReader As SqlDataReader
sqlReader = sqlCommand.ExecuteReader
DropDownList1.DataSource = sqlReader
DropDownList1.DataValueField = "ProductID"
DropDownList1.DataTextField = "ProductName"
DropDownList1.DataBind()
sqlReader.NextResult()
Dropdownlist2.DataSource = sqlReader
DropDownList1.DataValueField = "ShipperID"
DropDownList2.DataTextField = "CompanyName"
DropDownList2.DataBind()
sqlReader.NextResult()
Dropdownlist3.DataSource = sqlReader
DropDownList1.DataValueField = "EmployeeID"
DropDownList3.DataTextField = "LastName"
DropDownList3.DataBind()
sqlReader.Close()
sqlConnection.Close()
End If
End Sub
But its just not populating ..
what am i missing
Its populating the 3 DropDwonList but no Data?
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not IsPostBack Then
Dim sqlConnection As SqlConnection = New SqlConnection
sqlConnection.ConnectionString =
ConfigurationSettings.AppSettings("northwind")
sqlConnection.Open()
Dim sqlCommand As SqlCommand = New SqlCommand
sqlCommand.Connection = sqlConnection
sqlCommand.CommandText = "SELECT ProductName FROM
Products;SELECT CompanyName FROM Shippers;SELECT LastName FROM Employees"
Dim sqlReader As SqlDataReader
sqlReader = sqlCommand.ExecuteReader
DropDownList1.DataSource = sqlReader
DropDownList1.DataValueField = "ProductID"
DropDownList1.DataTextField = "ProductName"
DropDownList1.DataBind()
sqlReader.NextResult()
Dropdownlist2.DataSource = sqlReader
DropDownList1.DataValueField = "ShipperID"
DropDownList2.DataTextField = "CompanyName"
DropDownList2.DataBind()
sqlReader.NextResult()
Dropdownlist3.DataSource = sqlReader
DropDownList1.DataValueField = "EmployeeID"
DropDownList3.DataTextField = "LastName"
DropDownList3.DataBind()
sqlReader.Close()
sqlConnection.Close()
End If
End Sub