我有一个连接到Sql Server并获取一些值的控制台应用程序。在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);
我希望模式是动态的。是否可以在连接字符串中传递模式? 类似这样的东西不起作用:
Server=myserverIP;Database=myDataBase/dbo;User Id=user;Password=pass;Integrated Security=False;Connection Timeout=60
或者
Server=myserverIP;Database=myDataBase.otherSchema;User Id=user;Password=pass;Integrated Security=False;Connection Timeout=60
谢谢。