Database question

Results 1 to 4 of 4

Thread: Database question

  1. #1
    Matt1999 Guest

    Default Database question

    I&#039m just a beginner at ASP and I am trying to do a query in a database. I can display the whole database with this code:<BR><BR>&#060;%<BR>Set OBJdbConnection = Server.CreateObject("ADODB.Connection") <BR>OBJdbConnection.Open "DSN=Web400;UID=XXX;PWD=PASSWORD"<BR>OBjdbConnecti on.CommandTimeout=0<BR>SQLQuery = "SELECT * FROM QIWS.QCUSTCDT" <BR>Set RSCustomerList = OBJdbConnection.Execute(SQLQuery) <BR>%&#062;<BR>&#060;% Do While Not RScustomerList.EOF %&#062;<BR><BR>&#060;%= RSCustomerList("CUSNUM")%&#062; etc...<BR><BR>but how could I run a query? For Example,I would like to run a query that would display the customer (CUSTNUM Field) 188888&#039s information. <BR><BR><BR><BR>Thanks!!!!

  2. #2
    Join Date
    Dec 1969

    Default RE: Database question

    Dim strSQL, objRS<BR>Set ObjRS=Server.CreateObject("ADODB.Recordset")<BR>st rSQL = "SELECT CUSTNUM FROM Category WHERE CUSTNUM=188888;"<BR>objRS.Open strSQL, "DSN=Shopping;"<BR><BR>This is what I use, there may be a better more efficient way, but this works for me<BR><BR>Shaun

  3. #3
    Markkk Guest

    Default RE: Database question

    Modify you SQL Statement:<BR><BR>SQLQuery = "SELECT * FROM QIWS.QCUSTCDT WHERE CUSTNUM=" & "188888" <BR><BR>This of course assumes that the data field (CUSTNUM) exists in the data Table QCUSTCDT, and that the data field (CUSTNUM) is a numeric data type.

  4. #4
    Ravi Kanth S Guest

    Default RE: Database question

    Both these guys are right...<BR>I assume that You are trying to make the SQL statement dynamic based on the User&#039s selections.<BR><BR>If it is true....<BR><BR>Try to capture the value to be used in the &#039Where&#039 Clause from Request.Form or Request.Querystring collection and pass it to a varible then Use the varible in the where clause of the SQL statement.<BR><BR>If I was wrong Please let me know How U want Your SQL statement to be framed.<BR><BR>Happy Programming<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