更新时间:2023-02-02 21:40:13
您可以选择省略连接数据库
参数串。 。这样做,你到了数据库服务器的连接,但你没有连接到任何特定的数据库
You can optionally omit the database
parameter in connection string. Doing so, you get a connection to the database server but you are not connected to any specific database.
的从MySQL文档实例 :
Part of Example from MySQL documentation:
MySql.Data.MySqlClient.MySqlConnection conn;
string myConnectionString;
//myConnectionString = "server=localhost;uid=root;pwd=12345;database=test;";
myConnectionString = "server=localhost;uid=root;pwd=12345;";
try
{
conn = new MySql.Data.MySqlClient.MySqlConnection();
conn.ConnectionString = myConnectionString;
conn.Open();
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
MessageBox.Show(ex.Message);
}
但是,你必须使用数据库名称中限定表或其它对象名称。查询
But you have to use database name to qualify the table or other object names within your queries.
示例
select * from so.tbl_so_q23676633;
在上面的例子中,'所以'
是表的数据库预选赛'tbl_so_q23676633
。
In the above example, 'so'
is the database qualifier for table 'tbl_so_q23676633'
.