Invalid object name 'Accounts' <tablename>

W

weird0

I am testing a webservice locally that connects to BankingDb and
check the function

[WebMethod]
public bool CheckPincode(string Pincode)
{

SqlConnection sqlConnection1 =new
SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("SELECT acc_pincode FROM
Accounts WHERE acc_pincode=@PINCODE",sqlConnection1);
cmd.Parameters.AddWithValue("@PINCODE", Pincode);
sqlConnection1.Open();
Object obj = cmd.ExecuteScalar();
string result = obj.ToString();
sqlConnection1.Close();
if (result == Pincode)
return true;
else
return false;
}

It gives the above exception. how do i fix this ? I think it has
something to with user rights? The table might be created on different
users. How do i find out the users on my db and and create priveleges
and access them etc. etc. and solve my problem.
 
P

Pramod Anchuparayil

Make sure you are connecting to the correct server. The error says you are
trying to Access a non existent table.

Also run SQL Trace if you are sure the connection string is correct.
 
M

Milsnips

Hi there,

i've had a similar problem with table access on a web database and it was
the owner of the table, so i added "select * from dbo.[tablename]" and it
solved my problem..

Paul
 

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