Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need sql help 1

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
I have a form submitting to a processing page with the following fields

FirstName
LastName
Company

I'm trying to search all fields if the user has either filled all fields all left some blank. I don't know the syntax on how to do the search

<%
set rsSearch = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsSearch.ActiveConnection = MM_mydsn_STRING
rsSearch.Source = &quot;SELECT * FROM Client WHERE CL_Last = '&quot; Replace(rsSearch__MMColParam, &quot;'&quot;, &quot;''&quot;) and &quot;' or CL_First = &quot; + Replace(rsSearch__firstname, &quot;'&quot;, &quot;''&quot;) and &quot; or CL_Company = &quot; + Replace(rsSearch__company, &quot;'&quot;, &quot;''&quot;) + &quot;&quot;
rsSearch.CursorType = 0
rsSearch.CursorLocation = 2
rsSearch.LockType = 3
rsSearch.Open()
rsSearch_numRows = 0
if rsSearch.EOF then
response.redirect &quot;add.asp&quot;
end if
%>

Thanks in advance.




Delete * from brain Where MaxLevel = &quot;Full&quot; and reaction = &quot;Slow&quot; order by StartOver
 
SQL = &quot;SELECT * FROM client WHERE 1 = 1&quot;

IF trim(rsSearch__MMColParam) <> &quot;&quot; then
sql = sql & &quot; AND CL_Last = '&quot; Replace(rsSearch__MMColParam, &quot;'&quot;, &quot;''&quot;)
end if

'continue to use this syntax for each field...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
mwolf00/ or anyone, what am I replacing on my code? or am I simply adding your suggestion to the bottom of mine? Thanks

user.gif

There's never time to do it right, but there's always time to do it over!
 
never mind. I figured it out using mwolf00's suggestion. Thanks again

user.gif

There's never time to do it right, but there's always time to do it over!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top