how to open a table with a DSN-less connection?

Results 1 to 2 of 2

Thread: how to open a table with a DSN-less connection?

  1. #1
    Clinton Guest

    Default how to open a table with a DSN-less connection?

    I&#039ve managed to set up a DSN-less connection to my database, but I&#039m having<BR>trouble with the syntax to open a specific table. I know the DSN syntax is:<BR><BR> "tableName", "DSN=dsnName"<BR><BR>and one way of using the DSNless syntax to open the database is:<BR><BR><BR><BR>but where do I then put the table name to allow access by this through the<BR>recordset later?<BR><BR>many thanks for your help<BR><BR>Clinton Porter<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: how to open a table with a DSN-less connection

    I hardly ever refer to a db via it&#039s DSN name within the code. I access my db using the method below, hope it helps.<BR><BR>Dim path, conn, sql<BR>path = "c:Inetpubwwwrootdatadb"<BR>set conn= Server.CreateObject("ADODB.Connection")<BR>conn.Op en "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &path& "main.mdb"<BR><BR>And then create a recordset using something like this;<BR><BR>&#039*** Check for duplicate username, initials, first name and surname<BR>&#039 Set and create recordset with cursor types specified<BR>set rs = Server.CreateObject("ADODB.Recordset")<BR>sql = "SELECT Username FROM tblUsers"<BR>rs.Open sql, conn, adOpenStatic, adLockReadOnly, adCmdText<BR><BR>Note: Remember you must have the file referenced to specifiy the cursor types in the text format above, otherwise use the int values.<BR><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