I have got a console app that is connecting to a Sql Server and getting some values. I have the Schema in the Select(dbo):
var ds = new DataTable("test");
var connSqlRemoto = new SqlConnection("Server=myserverIP;Database=myDataBase;User Id=user;Password=pass;Integrated Security=False;Connection Timeout=60");
connSqlRemoto.Open();
var nombreBbdd = connSqlRemoto.Database;
var daASqlRemoto = new SqlDataAdapter();
var cmdSqlRemoto = new SqlCommand("SELECT * FROM " + nombreBbdd + ".dbo.myTable;", connSqlRemoto);
cmdSqlRemoto.CommandTimeout = 1200;
cmdSqlRemoto.Parameters.Clear();
daASqlRemoto.SelectCommand = cmdSqlRemoto;
daASqlRemoto.Fill(ds);
I want the Schema to be dynamic. Is it possible to pass the Schema in the connection string? Something like this is not working:
Server=myserverIP;Database=myDataBase/dbo;User Id=user;Password=pass;Integrated Security=False;Connection Timeout=60
or
Server=myserverIP;Database=myDataBase.otherSchema;User Id=user;Password=pass;Integrated Security=False;Connection Timeout=60
Thanks.