如何在连接字符串中获取没有数据库名称的mysql连接 [英] How to get mysql connection without database name in connection string

查看:108
本文介绍了如何在连接字符串中获取没有数据库名称的mysql连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在连接字符串中获取没有数据库名称的MySQL连接是一项挑战



任何人都可以帮助我获取连接而不提及数据库名称吗?



在SQLSERVER中我实现了它像

SqlConnection con = new SqlConnection(Data Source =localhost; Integrated Security = True;)



提前致谢。

It is challenge to get the MySQL connection without database name in connection string

Can any one help me to get the connection without mention database name?

In SQLSERVER i have achieve it like
SqlConnection con = new SqlConnection("Data Source="localhost"; Integrated Security=True;")

Thanks in advance.

推荐答案

使用 OLEDB

Using OLEDB
 // OleDb
using System.Data.OleDb;
OleDbConnection conn = new OleDbConnection(); 
conn.ConnectionString = "Provider=MySqlProv; Data Source=ServerName; User id=UserName; Password=Secret";
conn.Open(); 



找到它:此处 [ ^ ]


Found it: here[^]


这篇关于如何在连接字符串中获取没有数据库名称的mysql连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆