Reputation: 323
I run this code:
SqlConnection polaczenie;
polaczenie = new SqlConnection(dane_polaczenia);
SqlCommand cmd = new SqlCommand();
cmd.Connection = polaczenie;
polaczenie.Open();
cmd.CommandText = @"SELECT * FROM test.test";
cmd.ExecuteNonQuery();
After executing I got exception Invalid object name 'test.test'.
Database and table values are correct.
How to specify database.table
in CommandText
correctly?
Upvotes: 1
Views: 2204
Reputation: 107716
cmd.CommandText = @"SELECT * FROM test.dbo.test";
or
cmd.CommandText = @"SELECT * FROM test..test";
Upvotes: 1