Using AND

Results 1 to 2 of 2

Thread: Using AND

  1. #1
    Bonnie Guest

    Default Using AND

    I can not get this select statement to work I want the user to enter in the text box a city and state and be<BR>able to retrieve information about a person in that city and state...This is the code I have used..<BR><BR>The error is actually coming up on the include file.....<BR><BR><BR><BR>&#060;HEAD&#062;&#060;TIT LE&#062;sqlwhereform1respond.asp&#060;/TITLE&#062;&#060;/HEAD&#062;<BR>&#060;HTML&#062;&#060;body bgcolor="#FFFFFF"&#062;<BR>&#060;%<BR>myDSN="DSN=N OC1;uid=User;pwd=Web"<BR><BR>mystate=request.query string("st")<BR>mycity=request.querystring("ct")<B R>SQLtemp="select * from AblazeMembers where state=&#039 & city=&#039"<BR>SQLtemp=SQLtemp & mystate & mycity & "&#039"<BR><BR>call query2table(SQLtemp,myDSN)<BR>%&#062;<BR>&#060;!--#include virtual="/includes/lib_dbtable.asp"--&#062;<BR>&#060;/BODY&#062;&#060;/HTML&#062;<BR><BR>Include File:<BR><BR><BR>&#060;% <BR>sub query2table(inputquery, inputDSN)<BR> dim conntemp, rstemp<BR> set conntemp=server.createobject("adodb.connection")<B R> conntemp.open inputDSN<BR> set rstemp=conntemp.execute(inputquery)<BR> howmanyfields=rstemp.fields.count -1%&#062;<BR> &#060;table border=1&#062;&#060;tr&#062;<BR> &#060;% &#039Put Headings On The Table of Field Names<BR> for i=0 to howmanyfields %&#062;<BR> &#060;td&#062;&#060;b&#062;&#060;%=rstemp(i).name% &#062;&#060;/B&#062;&#060;/TD&#062;<BR> &#060;% next %&#062;<BR> &#060;/tr&#062;<BR> &#060;% &#039 Now lets grab all the records<BR> do while not rstemp.eof %&#062;<BR> &#060;tr&#062;<BR> &#060;% for i = 0 to howmanyfields<BR> thisvalue=rstemp(i)<BR> If isnull(thisvalue) then<BR> thisvalue="&nbsp;"<BR> end if%&#062;<BR> &#060;td valign=top&#062;&#060;%=thisvalue%&#062;&#060;/td&#062;<BR> &#060;% next %&#062;<BR> &#060;/tr&#062;<BR> &#060;%rstemp.movenext<BR> loop%&#062;<BR> &#060;/table&#062;<BR> &#060;%<BR> rstemp.close<BR> set rstemp=nothing<BR> conntemp.close<BR> set conntemp=nothing<BR>end sub%&#062;<BR><BR>

  2. #2
    Sathiya Guest

    Default RE: Using AND

    sqlstr = "Select * from Ablazemembers where state ="<BR>sqlstr = sqlstr & "&#039" & mystate & "&#039 "<BR>sqlstr = sqlstr & " and City = "<BR>sqlstr = sqlstr & " &#039" & mycity & "&#039"<BR><BR>display the sqlstr if u get errors Response.write sqlstr<BR>EX:<BR>select * from Ablazemembers from state = &#039CA&#039 and city = &#039LA&#039<BR>the sqlstring should be like the above example<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •