I did spend an hour searching before I posted about this problem.
The table does exist and I can query that table and I can see the resultset but when i try to execute from Visual Studio 2008 I get the below error:
Cannot find the object "Products" because it does not exist or you do not have permissions
Why does this error occur and what should I do to resolve it?
using (System.Data.SqlClient.SqlCommand cmd = connection.CreateCommand() as System.Data.SqlClient.SqlCommand)
{
cmd.CommandText = "SET IDENTITY_INSERT Products ON";
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
}
I tried specifying dbo.Products and before executing I also tried use dbname but that did not help.
after spent few hours and lost few hairs i found that the problem was in the connection strings (but this is still did not convence me) and as i said in question i was not having any issues but suddenly its pop-up and i havent change anything (who knows what dba have changed)
so I try tweak my connection string instead, and it does make a string
to see if it makes a difference: and it does.
the only thing i have added to my connection string is
Trusted_Connection= YesPS: SET IDENTITY_INSERT remains on for your session until
you turn it off, and it can only be on for one table at a time
Hope this will help others…