Hi
I have two drop downs and abutton, the button is supposed to send one of the items from one of the dropdowns to a qry (access database) and populate the datagrid with the info. It is not working propery- I press the button and it LOOKS Like something happens- but the datagrid does not populate.
I am not really sure how to troubleshoot this part... I can successfully pull data from the table without sending something to the WHERE... (like a select *) and populate the grid..
Sub Page_load(Sender As Object, Byval E As EventArgs)
If Not Page.IsPostBack Then
Dropdownlist1.DataTextField = "CompanyName"
Dropdownlist1.dataValueField= "ShipperID"
DropDownList1.DataSource = GetShippers()
DropDownList1.DataBind()
Label2.text=DropDownList1.selecteditem.value
End If
End Sub
Sub getlabel(byval sender As Object, ByVal e As EventArgs)
Label2.text=DropDownList1.selecteditem.value
End Sub
SUB Button1_click(byval sender As Object, ByVal e As EventArgs)
Call GETORDER()
datagrid1.visible=true
End Sub
FUNCTION GetShippers() As System.Data.DataSet
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\WEB_STUFF\AS"& _
"P\Northwind.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = "SELECT [Shippers].[ShipperID],[Shippers].[Companyname] FROM [Shippers]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End FUNCTION
FUNCTION GETORDER()
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\WEB_STUFF\AS"& _
"P\Northwind.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )
dim ShipVia = DropDownList1.selecteditem
Dim queryString As String = "SELECT [Orders].[OrderDate], [Orders].[ShipAddress] FROM [Orders] WHERE ([Orders]"& _
".[ShipVia] = " & ShipVia & ")"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim DSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(DSet)
DataGrid1.DataSource = dset
DataGrid1.DataBind()
return dset
End FUNCTION