-
I am writing a customer support application in VB 6.0 with MS SQL 7.0 backend.
I need to create a end user front end form to query the database by either typing in the fields directly as search parameters or using a query grid to build the query using comparison symbols.
ex . query grid contains a text box where user can enter field in database to search as in:
LName = "Smith" AND FName = "Susan"
or
DateOpened >= "01/01/2000"
I know this must require the use of dynamic SQL.
Thanks
-
try the following SELECT statement
assume that your table is tblData with three fields of interest, FName, LName, Date and that you have three textboxes: txtFName, txtLName, txtDate
Dim strFName as String
Dim strLName as String
Dim strDate as String
strFName = txtFName.Text
strLName = txtLName.Text
strDate = txtDate.Text
"SELECT * FROM tblData WHERE FName = ' " & strFName & " ' AND LName = ' " & strLName & " ' AND Date = ' " & strDate & " ' "
[note that there are no spaces between double quotes ( " ) and single quotes ( ' ).]
i hope this helps