DSN, table specific

Results 1 to 3 of 3

Thread: DSN, table specific

  1. #1
    Conrad Guest

    Default DSN, table specific

    Is there a way to specify which table you wish to use in a DSN?<BR><BR>Thanks.

  2. #2
    Join Date
    Dec 1969

    Default RE: DSN, table specific

    Do you mean you have this database, with say 10 tables, but only wish to connect to 1 of those tables w/ a DSN?? If so, then to the best of my knowledge, no. What you can do is set up your DSN to your database, then use SQL statements to select stuff from the table...like so:<BR><BR>&#060;%<BR>set dbcn=server.createobject("adodb.connection")<BR>db cn.open "dsn=mydsn"<BR>set dbrs=server.createobject("adodb.recordset")<BR>dbr s.activeconnection=dbcn<BR>dbrs.open "select * from mytable"<BR>dbrs.close<BR>dbcn.close<BR>set dbrs=nothing<BR>set dbcn=nothing<BR>%&#062;

  3. #3
    Curtis Guest

    Default RE: DSN, table specific

    well, that is a long way and uses SQL.. here is a quick simple<BR>way that has no SQL.. in case you don&#039t like SQL as myself.<BR>I personally don&#039t see a reason to use extra dataobjects for nothing so here&#039s what I use. (the book Active Server Pages 2.0 sample code showed me this stuff.)<BR><BR>--- start of example<BR>&#039opens a recordset using tblMain from Support.mdb, <BR>&#039pointed to by the DSN<BR>oRs = Server.CreateObject("ADODB.Recordset")<BR>oRs.Open "tblMain", "DSN=DSI;UID=;Password=;", adOpenKeyset, adLockBatchOptimistic, adCmdTable <BR><BR>oRs.BatchUpdate<BR>--- end of example<BR><BR>since the recset is opened "batchoptimistic" you must use<BR>oRs.BatchUpdate instead of just oRs.Update<BR>i did that so that more than one user can access the database<BR>at the same time. You can change it to adLockPessimistic, and<BR>then just use oRs.Update to save changes to the database.<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