Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Posts
    111

    Unanswered: I can connect, but I can't run SELECT query

    My vb code in my asp file successfully connects to a database I just set up and for which I created a DSN. But the SELECT query says Invalid object name MyTable:

    Code:
    	Dim oConn
    	Dim oRS
    	Dim strSQL
    	Dim dt
    	
    	Set oConn = Server.CreateObject("ADODB.Connection")
    	oConn.Open dbString
    	strSQL = "SELECT MyCol FROM MyTable WHERE MyOtherCol = '" & 1 & "'"
    	Set oRS = oConn.Execute (strSQL)
    The object/table definitely exists. I can open it in Query Analyzer. Any idea? Permission problem, maybe?

    Thanks.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Execute suggests an action (INSERT, UPDATE, CREATE...) you need to open the query resultset

    www.w3schools.com/ado should get you started
    George
    Home | Blog

  3. #3
    Join Date
    Jul 2006
    Posts
    111
    Thank you for the reply.

    I don't believe that is my problem. I am running production code. All I did was set up test databases locally and point to them instead of the production ones.

    Any other ideas?

  4. #4
    Join Date
    Jul 2006
    Posts
    111
    It was the DSN configuration that was wrong.

    Forever etched in my mind is the importance of that little checkbox that says Change the default database to:

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •