Syntax help - connection to database

Results 1 to 2 of 2

Thread: Syntax help - connection to database

  1. #1
    Join Date
    Dec 1969

    Default Syntax help - connection to database

    Hello!Could somebody help me out with the syntax I need to connect to a database using a DSN name that I've successfully set up.I would like to "SELECT * FROM tableName", then print the first field within the recordset. I simply cannot remember the syntax of how to do this!Thanks.
    Digital vaporizer
    Last edited by Jay; 04-16-2011 at 01:17 AM.

  2. #2
    Vijaya Seshan Guest

    Default RE: Syntax help - connection to database

    Here is the code:<BR>cnstr =";UID=sa;PWD=;DSN=dsnname;" (if it is a system dsn)<BR>cnstr ="FILEDSN=c:dsnname.dsn" (if it is a file dsn then specify the path)<BR>Set cn = Server.CreateObject("ADODB.Connection")<BR>Set rs = Server.CreateObject("ADODB.Recordset")<BR> cnstr<BR>sSql = "select * from tablename"<BR> sSql,cn<BR>&#039;now you can iterate through the recordset using<BR>while not rs.eof<BR>response.write rs.fields(0)<BR>rs.movenext<BR>wend<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