SqlExeption: Invalid object name 'TABLE'

G

Guest

Hi,

I'm using the following command to access information on a SQL Database and
everything works fine.

Dim oSqlCommand As New SqlClient.SqlCommand
oSqlCommand.CommandType = CommandType.Text
oSqlCommand.Connection = mSqlConnection
oSqlCommand.CommandText = "SELECT * FROM TABLE"

Dim oSqlReader As SqlClient.SqlDataReader
oSqlReader = oSqlCommand.ExecuteReader
oSqlCommand.Dispose()

Therefore, as soon as I change the userID and the Password of the Connection
String, I've got the following error: Invalid Object name 'TABLE'

With the new userID and Password, the connection is established and the
TABLE table is present. Therefore, I could not access it.

What I have noticed is that only the owner of the TABLE could access the
TABLE. As soon as I tried to access the TABLE with another user, I could not
get the information.

Does someone know how to solve the problem?

Thanks,
 
W

W.G. Ryan eMVP

Just as an FYI - if you're passing in variables to build the
connectionstring - don't - it's a huge security risk.

As far as your problem - make sure your user has permissions to access the
table in question - if it works with the owner than that's the most likely
culprit.
 
G

Guest

Thanks for the FYI.

On my SQL server, I have two user with the same Type and Server Access.
The userID that is able to access the TABLE have a lower security level.
The userID that is unable to access the TABLE have the Highest security
level. He is the System Administrator and the entire DB owner.

Note: While performing my query throught Excel, everything works fine with
both userID.

Thanks
 
P

Patrice

Try also to enclose the name in [] as you are using a reserved word...

Patrice

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top