473,569 Members | 2,839 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_datarea der" and "db_datawri ter"
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.Connectio n
conn.Open "DSN=TestDSN;UI D=Tester;PWD=te st"

Set cmd = New ADODB.Command
cmd.ActiveConne ction = 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 20983
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

"FreeOperat or" <an******@yahoo .com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.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_datarea der" and "db_datawri ter"
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.Connectio n
conn.Open "DSN=TestDSN;UI D=Tester;PWD=te st"

Set cmd = New ADODB.Command
cmd.ActiveConne ction = 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

"FreeOperat or" <an******@yahoo .com> wrote in message
news:11******** **************@ l41g2000cwc.goo glegroups.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****@sommarsk og.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

"FreeOperat or" <an******@yahoo .com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.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("A DODB.Connection ")
SQLConn.Open "DSN=TestDSN;UI D=Tester;PWD=te st"
Set rs = SqlConn.Execute ("SELECT USER")
MsgBox Rs.Fields(0)
rs.Close
SQLConn.Close

--
Hope this helps.

Dan Guzman
SQL Server MVP

"FreeOperat or" <an******@yahoo .com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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

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

Similar topics

2
5739
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. Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E37) Invalid object name 'itemSecUsers'.
2
13883
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 works great. Then when the insert loop runs, I get this error on the following line. insert into data1 ('AdminManageLogIn','Password') Values...
3
4664
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 like the code couldn't identify the table. any idea of what could be wrong? thanks
1
2342
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: myCommand.Fill(ds) Help appreciated. Thanks - Frank <code>
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 { myCommand.ExecuteNonQuery();
2
2687
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. Please review the stack trace for more information about the error and where it originated in the code. Exception Details:...
2
6589
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 views that access tables on the other (linked) server, I can not modify any data, because I get the Invalid object name server.database.dbo.TableName...
3
7412
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". Mixed mode authentication specified and sa password specified. Used server manager to create user login with sysadmin role. Login using windows...
1
1650
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 ID="SqlDataSource1" runat="server" ConnectionString="<%$ConnectionStrings:monishaCS%>" SelectCommand="SELECT , , ,
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6281
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5509
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5218
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.