Get "Invalid object name '{table name}'" when trying to connect to SQL Server through ASP (VBScript)

Posted on 2003-03-11
Medium Priority
Last Modified: 2008-03-06

Can anyone help me? First of all let me summarise the server enviromnent:

Web server:
NT 4.0
Using ASP pages with VBScript

SQL Server:
SQL Server 2000
NT 4.0

Here's the problem. I am trying to connect to SQL server from our web server. This is the connection code held in connection.asp:

Dim dbConn,rs
Set dbConn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset")
dbConn.ConnectionString = "Description={DESCRIPTIOPN};DRIVER=SQL Server;UID={UID};PWD={PWD};SERVER={SERVER}"
dbConn.ConnectionTimeout = [5]
Response.write "Connection succeeded"

Here is the code that causes the error:

<!-- #INCLUDE FILE="connection.asp" -->

Dim SqlText,lnCLogNo,cnn
SqlText = "Select max(clogno) AS MaxClog from CLog"
*****ERROR OCCURS HERE!!!*******
rs.Open SqlText,dbConn

And here is the error:

Connection succeeded
Microsoft OLE DB Provider for ODBC Drivers error '80040e37'

[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'CLog'.

As you can see the Connection succeeded but it can't find the table "CLog". I have double-checked and CLog is definitely there.

I have set up a ODBC data source on the web server (DSN) and have verified the connection - it succeeded.

Is the connection string incorrect?

Your help would be appreciated!

Question by:kaiwhoeatspie

Accepted Solution

Hummusx earned 500 total points
ID: 8111164
Just a couple thoughts.  Are you specifying in the ODBC datasource which database for it to use?  That could be causing a problem if it doens't know which DB in the sql server to hit.  Also, you should try putting [] around your field/tbl names.  Oh yeah, and drop the connection time out for the moment.

Is this the only place you are having trouble?  Do the rest of your db access pages work fine?

Author Comment

ID: 8111561

Thanks for your answer, Hummusx.

To answer your questions:
- I only used the data source to test the connection. But yes, I specified the exact database.
- I have only put the {} as placeholders. Sorry if that wasn't clear.

Actually, I found the problem not 15 minutes ago.

The problem was that in IIS I set the default ASP language to JavaScript. When I set it to VBScript and then replaced the <SCRIPT LANGUAGE="VBScript" RUNAT="Server"> tags to just <% it worked!

Thanks for trying to help though, Hummusx. Much appreciated.

What do I do now? My question in no longer valid as I somehow managed to find the solution myself.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
Suggested Courses
Course of the Month8 days, 21 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question