473,508 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help! SQL Server error - [Microsoft][ODBC SQL Server Driver][SQL Server] Invalid object name ...

Dear all,

On Win2000 server with SP3, I am trying to access a SQL Server 7.0
database, "TestDB", from VB6 via a SQL Server ODBC system DSN using ADO
2.7. In SQL Server Enterprise Manager, there is a login named "Tester".
In its property window, NO "Server Roles" was assigned but its
"Database Access" was set to "TestDB". This login was also made as the
user of "TestDB" with "public", "db_datareader" and "db_datawriter"
selected as its "Database role membership". All the tables I am trying
to access in "TestDB" were created under "Tester".

My code is like:

Set conn = New ADODB.Connection
conn.Open "DSN=TestDSN;UID=Tester;PWD=test"

Set cmd = New ADODB.Command
cmd.ActiveConnection = conn
cmd.CommandText = SQL

set rs = cmd.Execute()

If I set the SQL to something like "SELECT * FROM tbl_test", I always
get an error of "-2147217865" saying "[Microsoft][ODBC SQL Server
Driver][SQL Server] Invalid object name tbl_test". If I set the SQL to
"SELECT * FROM Tester.tbl_test", everything runs properly. Could anyone
please kindly advise why the first SQL is not working? Or in other
words, why must I prefix the table name with its owner while the DB
connection is already made under that owner name? Thanks in advance.

Tracy

Jul 23 '05 #1
10 20961
I likely cause is that your ODBC DSN is setup for integrated security
instead of SQL authentication. The user id in the connection string is then
ignored and the connection is made using Windows authentication. The object
isn't found because the current user isn't 'Tester'.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"FreeOperator" <an******@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Dear all,

On Win2000 server with SP3, I am trying to access a SQL Server 7.0
database, "TestDB", from VB6 via a SQL Server ODBC system DSN using ADO
2.7. In SQL Server Enterprise Manager, there is a login named "Tester".
In its property window, NO "Server Roles" was assigned but its
"Database Access" was set to "TestDB". This login was also made as the
user of "TestDB" with "public", "db_datareader" and "db_datawriter"
selected as its "Database role membership". All the tables I am trying
to access in "TestDB" were created under "Tester".

My code is like:

Set conn = New ADODB.Connection
conn.Open "DSN=TestDSN;UID=Tester;PWD=test"

Set cmd = New ADODB.Command
cmd.ActiveConnection = conn
cmd.CommandText = SQL

set rs = cmd.Execute()

If I set the SQL to something like "SELECT * FROM tbl_test", I always
get an error of "-2147217865" saying "[Microsoft][ODBC SQL Server
Driver][SQL Server] Invalid object name tbl_test". If I set the SQL to
"SELECT * FROM Tester.tbl_test", everything runs properly. Could anyone
please kindly advise why the first SQL is not working? Or in other
words, why must I prefix the table name with its owner while the DB
connection is already made under that owner name? Thanks in advance.

Tracy

Jul 23 '05 #2
Hi Dan,

Thank you for your kind reply, but I've picked "SQL authentication" for
my system ODBC DSN. I guess It must be something wrong with the user
permission settings in SQL Server 7.0. Just don't know what it is :-(

Thanks,
Tracy

Jul 23 '05 #3
Is your SQL Server configured to allow both SQL Server and Windows? This
will also force Windows authentication instead of SQL auth.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"FreeOperator" <an******@yahoo.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
Hi Dan,

Thank you for your kind reply, but I've picked "SQL authentication" for
my system ODBC DSN. I guess It must be something wrong with the user
permission settings in SQL Server 7.0. Just don't know what it is :-(

Thanks,
Tracy

Jul 23 '05 #4
FreeOperator (an******@yahoo.com) writes:
If I set the SQL to something like "SELECT * FROM tbl_test", I always
get an error of "-2147217865" saying "[Microsoft][ODBC SQL Server
Driver][SQL Server] Invalid object name tbl_test". If I set the SQL to
"SELECT * FROM Tester.tbl_test", everything runs properly. Could anyone
please kindly advise why the first SQL is not working? Or in other
words, why must I prefix the table name with its owner while the DB
connection is already made under that owner name? Thanks in advance.


In addition to Dan's post, run a "SELECT USER" to see who you really
are.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #5
Hi Dan,

Thank you again for your kind reply. My SQL Server authentication has
been set to both NT and SQL server, so it shouldn't be a problem ...

Tracy

Jul 23 '05 #6
You might try connecting with Query Analyzer using the Tester login and
running the SELECT USER query Erland suggested.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"FreeOperator" <an******@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi Dan,

Thank you again for your kind reply. My SQL Server authentication has
been set to both NT and SQL server, so it shouldn't be a problem ...

Tracy

Jul 23 '05 #7
Thanks Dan, thanks Erland. "SELECT USER" sounds like a good idea. I'll
implement a test function in my VB DLL to do it. Since the problem
server is hosted by another company and it will take them days
(considering the easter holiday) to update my DLL and run the test for
me. Will let you know the result when I get it.

Thanks again,
Tracy

Jul 23 '05 #8
The VBScript below should provide the same results as your test app as long
as the connection string is the same. Perhaps a script version can expedite
the test.

Dim SQLConn, rs
Set SQLConn = CreateObject("ADODB.Connection")
SQLConn.Open "DSN=TestDSN;UID=Tester;PWD=test"
Set rs = SqlConn.Execute("SELECT USER")
MsgBox Rs.Fields(0)
rs.Close
SQLConn.Close

--
Hope this helps.

Dan Guzman
SQL Server MVP

"FreeOperator" <an******@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Thanks Dan, thanks Erland. "SELECT USER" sounds like a good idea. I'll
implement a test function in my VB DLL to do it. Since the problem
server is hosted by another company and it will take them days
(considering the easter holiday) to update my DLL and run the test for
me. Will let you know the result when I get it.

Thanks again,
Tracy

Jul 23 '05 #9
Hi Dan and Erland,

Finally got the result of my test script. "SELECT USER" reveals that
the DB user is "dbo" instead of "Tester" although my ODBC connection
string explicitly specifies the user to be "Tester". That's really
weird. Maybe I need to run "SETUSER Tester" directly after the DB
connection is made to make sure the user is correct. Still don't know
what goes wrong there :-(

Thanks,
Tracy

Jul 23 '05 #10
Hi

Looks like Tester either owns the database or has sysadmin privileges (which
they probably should not have!). sp_changedbowner can change the database
ownership, sp_dropsrvrolemember can be used to remove the login from the
server role.

John

"FreeOperator" <an******@yahoo.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
Hi Dan and Erland,

Finally got the result of my test script. "SELECT USER" reveals that
the DB user is "dbo" instead of "Tester" although my ODBC connection
string explicitly specifies the user to be "Tester". That's really
weird. Maybe I need to run "SETUSER Tester" directly after the DB
connection is made to make sure the user is correct. Still don't know
what goes wrong there :-(

Thanks,
Tracy

Jul 23 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5738
by: MyATiX | last post by:
Can someone please tell me why I keep getting the following error? I think it is part of the connection but can't pin down the exact error. I would be grateful if someone might have any ideas. ...
2
13876
by: rockie12 | last post by:
I have a db that has a table x in it called data1 I have a program that does to things, updates values in the data1 table and also inserts new rows into this table. The update existing values...
3
4661
by: Reb | last post by:
Hi, I am using MSSQL server 2000. When i am running my code, i am getting the error System.Data.SqlClient.SqlException: Invalid object name 'Item' where Item is the name of a table. It seems...
1
2335
by: Frank Py | last post by:
I'm getting the following error when trying an example app: Invalid object name 'Products'. Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'Products'. Line 22:...
3
3663
by: Mr.KisS | last post by:
Hello all, I'm working with : WinXP PRO SP1, MS SQL 2005 Express, Visual Web Dev 2005 Express. I have an aspx page which must execute a stored procedure : ______________ try {...
2
2680
by: Jerry Nelson | last post by:
I get the following error: WGA_Update is a view not a Table Invalid object name 'WGA_Update'. Description: An unhandled exception occurred during the execution of the current web request....
2
6586
by: MrByte | last post by:
Hi Folks, I'm having a strange situation here between 2 Linked MS SQL 2K servers. One of the servers died recently and I rebuilt it. All seems to be working fine, except that when I create...
3
7404
by: ianforgroupuse | last post by:
I'm running Vista Business edition on 2005 Virtual PC. Installed SQL Server 2005 Express latest download, with instance of MSSQLSERVER and service accounts running under "NT AUTHORITY\SYSTEM"....
1
1644
by: moni | last post by:
Hi, I am using a table named PersonInfo in my database monisha in the SQL server. I need to use this in a .aspx file , but its giving me the error of invalid object name. <asp:SqlDataSource...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.