?
Solved

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

Posted on 2003-03-11
2
Medium Priority
?
962 Views
Last Modified: 2008-03-06
Hi

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

Web server:
IIS 4
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:

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
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]
dbConn.Open
Response.write "Connection succeeded"
</SCRIPT>

Here is the code that causes the error:

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

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Dim SqlText,lnCLogNo,cnn
SqlText = "Select max(clogno) AS MaxClog from CLog"
*****ERROR OCCURS HERE!!!*******
rs.Open SqlText,dbConn
*****************************
...
</Script>

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!

Regards
0
Comment
Question by:kaiwhoeatspie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
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?
0
 

Author Comment

by:kaiwhoeatspie
ID: 8111561
Hi,

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.

Kai
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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