我有一个情况我确实需要通过使用获得到MySQL所需的连接字符串创建一个数据库到MySQL server.Till我现在已经用于数据库的名字。所以在这种情况下的ConnectionString会是怎样的结构的ConnectionString执行我创建数据库查询到MySQL服务器。
I have got a situation where i do need to create a database into MYSQL by using the connection string needed to get into mysql server.Till Now i have used connectionstring with database names .So in this situation what will be the connectionstring structure to execute my create database queries into mysql server.
我需要的ConnectionString本地主机。
I need the Connectionstring for localhost ..
请帮忙我..
推荐答案您可以选择省略连接数据库参数串。 。这样做,你到了数据库服务器的连接,但你没有连接到任何特定的数据库
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'.
更多推荐
无数据库名称的MySQL的ConnectionString建立在C#中的数据库
发布评论