I am struggling to discover what the right syntax for my code would be.
I use VWebDeveloper Express 2005 and I have a web form .On the Web form I have three dropdowns that are bound through datasets and a textbox.Dropdowns are linked to display only the info relevant to the selection in the precedenig dropdown.What I want to achieve with the Text box is to display the result from a sql query, in which sql query I use the currently selected dropdown values .
However I seem to not get the syntax in the sql statement right.
Here is what I have as code in the third dropdown selected index changed event.
Protected Sub DDEntryType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DDEntryType.SelectedIndexChanged Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DB\databasename.mdb") Dim strSQL As String = "select max(RepPeriod) from Table where CompanyName= " & DDCompanyName.SelectedValue And CompanyType= "&DDCompanyType.SelectedValue and EntryType = " & DDEntryType.SelectedValue" Dim da As New System.Data.OleDb.OleDbDataAdapter(strSQL, conn) Dim ds As New Data.DataSet da.Fill(ds, "Table") tbLastEnteredRepPeriod.Text = ds.Tables(0).Rows(0)(0) End Sub
When I debug I get the following error:
BC30451: Name 'EntryType' is not declared
It`s clearly something to do with the sql statement. I just don`t really know how in different way I can get the query touse the currently selected values in the dropdown and return a single result that will be displayed in the text box.
Any help will be appreciated.
Thanks in advance