views:

59

answers:

4

In VS2005, I am using a DLL which accesses a SQL Server. The DLL returns a SQLException

Invalid object name 'tableXYZ'

but tableXYZ is a table in the database.

Should it be looking for dbo.tableXYZ instead? Is this a permissions issue with the login being used?

A: 

you have to use the databasename in your connection-string - otherwise it would just connect und you have to use dbo.databasename.tableXYZ.

you can find the various connection-strings here

Gambrinus
I cannot alter the code that connects to the database because it is in a compliled DLL.
Craig Johnston
+1  A: 

Using dbo.tableXYZ makes it clearer what you want - the tableXYZ in the default dbo schema. There could be a tableXYZ in another schema, too - then SQL Server might not know which one you want.

And it could most definitely be a permissions issue. If you connect to that database in SQL SErver Mgmt Studio as that user - can you see that tableXYZ table??

UPDATE: does the DLL require a specific connection string, that you might not have copied into your calling app's app.config file?? DLL's in .NET can't really have their own mylibrary.dll.config - it will not be read by .NET by default.

marc_s
Yes I can. I should note that I do not have the source code to the DLLs, so I all I can do is alter the settings on the SQL Server.
Craig Johnston
Reply to "UPDATE": No, there doesn't appear to be any .config file. Can I infer that the connection is being made successfully and that the issue is one of schemas/permissions?
Craig Johnston
A: 

This could be an issue with the owner of the tableand permissions.

for example the table owner may be dbo so the full table name will be dbo.TableXYZ The user you connect as, could be for example SQLUser may not have access to the dbo schema. So can only access tables such as SQLuser.TableXYZ

I'd check the permissions that you use to connect to the database.

Barry
I cannot alter the code that connects to the database because it is in a compiled DLL.
Craig Johnston
You don't need alter the DLL - you need to check that the user connecting to the database has access to the schema that the table belongs to.
Barry
A: 

As a starting point, you could turn on an SQL Server Profiler trace, to see how the DLL is connecting to the database. e.g. you should be able to see what credentials are being used. You could also confirm to make sure the code is connecting to the right database etc.

Moe Sisko