Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP SQL Script problem

Status
Not open for further replies.

telesync

Programmer
Sep 27, 2002
4
US
I have a problem when i am trying to query table that have space in the name. For eg i have table "part master". when i use a asp page to query this table it gives me an error

the script that have written is as shown below
<html>
<head>
<meta NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>

<body>

<%

Dim objConn
Set objConn = server.CreateObject(&quot;ADODB.Connection&quot;)
objConn.ConnectionString = &quot;DSN=test&quot;
objConn.Open

' this gives an error on execute here part master is a table
' name
mysql =&quot;SELECT * FROM [part master];&quot;
set rstemp=objconn.execute(mysql)

if rstemp.eof then
Response.write &quot;<br>No records matched&quot;
Response.write mysql
objconn.close
set objconn=nothing
response.end
end if
%>

<%
'rstemp.close
'set rstemp=nothing
objConn.Close
set objConn=nothing
%>
</body>
</html>

there is no way i can change name of the tables. ERROR that i get when i run the asp page is

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Pervasive][ODBC Engine Interface]Syntax Error: SELECT * FROM << ??? >>[part master];

Any help will be greatly appreciated!!!!!!!

thanks in advance
telesync
 
The &quot;test&quot; DSN on your machine: does it have a default db selected. You are opening an ADO connection using the ODBC DSN, but if the DSN doesn't have a default db, the SQL engine doesn't know which database to execute your statement against. It attempts to find your table in the &quot;master&quot; db, and if it doesn't find it there, it will return an error.

The other potential problem is which user on the db owns the table. Is it dbo? If it isn't, you need to qualify your table name writing [username].[part table].
 
The error message says that you are using the Pervasive ODBC driver. You may want to post the question in forum318 if using a Pervasive database. The ODBC driver may have different requirements from the SQL Server driver. If using SQL Server you should change the DSN to use the correct driver.

You may find that using double quotes rather than brackets around the table name may work - &quot;part table&quot;. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top