If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > I can connect, but I can't run SELECT query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-03-08, 10:45
M Mock M Mock is offline
Registered User
 
Join Date: Jul 2006
Posts: 111
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.
Reply With Quote
  #2 (permalink)  
Old 03-03-08, 11:15
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Execute suggests an action (INSERT, UPDATE, CREATE...) you need to open the query resultset

www.w3schools.com/ado should get you started
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 03-03-08, 11:38
M Mock M Mock is offline
Registered User
 
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?
Reply With Quote
  #4 (permalink)  
Old 03-03-08, 12:45
M Mock M Mock is offline
Registered User
 
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!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On