Hi Vijay,
Sorry for the lack of explanation. I'm still very new to writing SQL and relatively new to ASP. Here is what I'm trying to do. I'm trying to query one field in a database that has 435 enteries. The field I want to query contains and combination of text and numbers. Here are several examples of prod_number field entries:
cml 10-160s gzi
cml2_8sga
ml8sg
cml 12sgavd
On the search page:
www.dwayneepps.com/test/search.asp
I'm have a text field where a user can type in the exact product number or a portion of of the product number. The user then can choose from the menu how to search for the string in the text field.
So, from the example product number above. A user can type in:
ml8sg and then choose exact from the menu and the search would return the exact match in the database prod_number field.
Or, the user could simply type in:
ml and then choose begins with or ends with or contains and the search would return the matches in the database prod_number field that begin, end or contain the string typed in the text field depending on which menu choice they made. So, if they choose "Begins with" the search would look for entries in the database prod_number that begins with ml (the value of the string typed into the text field).
So, on the results page. I first tried to capture the value of the text field.
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.Form("txtKeywords") <> "") Then
Recordset1__MMColParam = Request.Form("txtKeywords")
End If
%>
Then I tried to capture the value of the menu field and build SQL statements that would return the appropriate matches in the prod_nuber field according to the case of the menu of selection:
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_DBConn_STRING
strTest = Request.Form("selMatchType")
Select Case strTest
Case "Exact"
Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
Case "Ending"
Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
Case "Contain"
Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
Case "Begin"
Recordset1.Source = "SELECT * FROM tblProducts WHERE prod_number = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
End Select
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
I'm guessing my SQL statements are wrong and not correctly identifying the criteria I'm specifying? Does this give a better idea of what I'm trying to do? I hope I made this explanation clearer. Please let me know if I can provide any additional information.
Thank you for your help. I appreciate it.
-Dman100-