SQL Server 2005: Invalid Object Name Exception

In VS2005, I am using a DLL that talks to SQL Server. DLL returns SQLException

Invalid object name 'tableXYZ'

but tableXYZ is a table in the database.

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

+2


a source to share


4 answers


This can be a problem with table owner and permissions.

for example the owner of the table might be dbo

, so the fully qualified name of the table would be dbo.TableXYZ

. The user you are connecting with may, for example SQLUser

, may not have access to the schema dbo

. This way only tables can be accessed likeSQLuser.TableXYZ



I would check the permissions you are using to connect to the database.

+1


a source


Usage dbo.tableXYZ

simplifies what you want - tableXYZ

in the dbo

default schema . In another schema, there may be and tableXYZ

- then SQL Server may not know which one you need.

And that could definitely be a permissions issue. If you connect to this database in SQL SErver Mgmt Studio as this user, you can see that the tabletableXYZ



UPDATE: Does the DLL need a specific connection string that you might not have copied into the app.config file of your calling application? A DLL in .NET cannot really have its own mylibrary.dll.config - it won't be read by .NET by default.

+1


a source


you need to use dbname in your connection string - otherwise it will just connect and you will need to use dbo.databasename.tableXYZ.

you can find various connection strings here

0


a source


As a starting point, you can enable SQL Server Profiler tracing to see how the DLL connects to the database. for example, you should be able to see what credentials are being used. You can also confirm that the code is connected to the right database, etc.

0


a source







All Articles