Reading from a database

Results 1 to 4 of 4

Thread: Reading from a database

  1. #1
    Needing your help Guest

    Default Reading from a database

    I&#039;m trying to read from two tables in an Access database<BR><BR>strSQL="SELECT * FROM Customer WHERE customer_ID="&customer&"" <BR>Set objRS= Server.CreateObject("ADODB.RecordSet") <BR>objRS.Open strSQL,objConn,adOpenDynamic,adLockOptimistic <BR><BR>strSQL2="SELECT * FROM Login WHERE customer="&name&"" <BR>Set objRS2= Server.CreateObject("ADODB.RecordSet") <BR>objRS2.Open strSQL2,objConn,adOpenDynamic,adLockOptimistic <BR><BR>Can anyone see whats wrong???<BR>

  2. #2
    Musician Guest

    Default RE: Reading from a database

    When the critera is using a number field all you need is :-<BR><BR>strSQL="SELECT * FROM Customer WHERE customer_ID=" & customer<BR><BR>assuming it&#039;s a number. For strings like the name criteria use the following:-<BR><BR>strSQL2="SELECT * FROM Login WHERE customer=&#039;" & name & "&#039;"<BR><BR>Ensure you have the spaces between the & and the variables etc. <BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Reading from a database

    strSQL2="SELECT * FROM Login WHERE customer="&name&"" <BR><BR>Name prolly is a string value? As in NOT a numeric value?<BR>In that case it should be:<BR>strSQL2="SELECT * FROM Login WHERE customer=&#039;"&name&"&#039;" <BR><BR>

  4. #4
    Cynthia V. Penyak Guest

    Default RE: Reading from a database

    Where you put spaces, quotes, ampersands and apostrophes is important - Here is a sample that demonstrates how to wrap code from one line to the next, and use three forms of criteria, including one (grade) that has a data type of number which is important should you wish to sort by grade...<BR><BR>sqlString = "Select * FROM qrySchools " &_<BR>"where staffid=&#039;" & staffid & "&#039; " &_<BR>"AND CInt( ( Grade ) )=&#039;" & grade & "&#039; " &_<BR>"AND school=&#039;" & School & "&#039; ; " <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