Use mysql-connector-net-5.1.7-noinstall
Web. Config File Settings
<Deleetask>
<Add key = "connstr" value = "Server = fengsulei \ sql2005; database = new_tes; uid = sa; Pwd = sa"/>
<Add key = "yycc" value = "Server = localhost; database = ftdms; uid = root; Pwd = 123456"/>
</Appsettings>
In the bin folder
MySQL. Data. dll
Uniformly introduce Database Connection Files
Using system;
Using system. Data;
Using system. Data. sqlclient;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. htmlcontrols;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
/// <Summary>
/// Database Class
/// </Summary>
Public class DB
{
Public String strconn = configurationsettings. receivettings ["connstr"];
}
Public class my
{
Public String mystr = configurationsettings. receivettings ["yycc"];
}
The method used on the page is similar to that used in the MSSQL database.
using system;
using system. data;
using MySQL. data;
using MySQL. data. mysqlclient;
using system. configuration;
using system. collections;
using system. web;
using system. web. security;
using system. web. ui;
using system. web. UI. webcontrols;
using system. web. UI. webcontrols. webparts;
using system. web. UI. htmlcontrols;
Public partial class MYSQL: system. web. UI. page
{< br> my DB = new my ();
protected void page_load (Object sender, eventargs E)
{< br> mysqlconnection mycon = new mysqlconnection (dB. mystr);
mycon. open ();
mysqlcommand mycmd = new mysqlcommand ("select * From ftdms_admin where id =? ID ", mycon);
{< br> mycmd. Parameters. addwithvalue ("? ID ", 1);
}
Mysqldatareader myreader = mycmd. executereader ();
While (myreader. Read ())
{
If (myreader. hasrows)
{
Response. Write (myreader. getstring ("admin_user") + "<br/> ");
}
}
Myreader. Close ();
Mycon. Close ();
}
}
OK.