c#連接mysql數(shù)據(jù)庫的方法
更新時(shí)間:2014年04月25日 11:44:45 作者:
這篇文章主要介紹了c#連接mysql數(shù)據(jù)庫的方法,需要的朋友可以參考下
使用vs2010連接mysql 數(shù)據(jù)庫,
1.裝連接驅(qū)動,使用Connector/Net 連接驅(qū)動!下載地址:http://dev.mysql.com/downloads/connector/net/, 安裝完之后,在項(xiàng)目中添加引用 Mysql.Data.dll;
2.配置連接串:
在web.config 中
復(fù)制代碼 代碼如下:
<configuration
<connectionStrings>
<addname="MysqlConnection"connectionString="server=localhost;userid=root;password=123456;database=test1;"/>
</connectionStrings>
</configuration
后臺代碼中:
復(fù)制代碼 代碼如下:
string sqlstring = System.Configuration.ConfigurationManager.ConnectionStrings["MysqlConnection"].ConnectionString;
MySqlConnection myconn=new MySqlConnection(sqlstring);
myconn.Open();
相關(guān)文章
C#中的只讀結(jié)構(gòu)體(readonly struct)詳解
這篇文章主要給大家介紹了關(guān)于C#中只讀結(jié)構(gòu)體(readonly struct)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11WindowsForm移動一個(gè)沒有標(biāo)題欄的窗口的方法
這篇文章主要介紹了WindowsForm移動一個(gè)沒有標(biāo)題欄的窗口的方法,文中講解非常細(xì)致,代碼幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下2020-07-07