Results 1 to 2 of 2

Thread: SQL 'USE DATABASE' question

  1. #1
    Join Date
    Dec 1969

    Default SQL 'USE DATABASE' question

    I used to use Access , using a DSN and conect to the database with<BR>objConn.Open "DSN=myDSN"<BR>&#039;<BR>&#039;<BR>objRS.Open strSql, objConn<BR>then just call the table I wanted in the sql string<BR>Now I&#039;m using sql 2000, I have to add &#039;Using Mydatabase&#039; before accessing the table like this<BR>strSQL="Use MyDatabse Select * from MyTable"<BR>The DSN used to open the database connects to the right one, so why do I need to use the&#039;Use&#039; statement?<BR>How do I put the Use statement in <BR><BR>Set objRS = Server.CreateObject("ADODB.Recordset")<BR>objRS.Op en "MyTable", objConn, ,adLockOptimistic, adCmdTable<BR><BR>Thanks for any help<BR>Greg<BR>

  2. #2
    Kevitt Guest

    Default RE: SQL 'USE DATABASE' question

    If your DSN has the default database set, and that is the DB you want to work with, then you really do not need to use &#039;USE myDB&#039;.<BR><BR>However, sometimes there are situations where you would not be connecting via a DSN with a default database that is the one you need to query. That&#039;s when you can specify which DB to use.<BR><BR>Or, in other cases, there may be no default DB specified intentionally, and also identically named tables in different DBs. Here again, you would want to specify which DB to query.<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