无数据库名称的MySQL的ConnectionString建立在C#中的数据库

编程入门 行业动态 更新时间:2024-10-28 09:13:28
本文介绍了无数据库名称的MySQL的ConnectionString建立在C#中的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个情况我确实需要通过使用获得到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#中的数据库

本文发布于:2023-10-24 02:49:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1522722.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   名称   ConnectionString   MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!