c connects to the mysql database
- 2020-06-23 01:46:10
- OfStack
Connect to the mysql database using vs2010,
1. Install the connected driver, use Connector/Net connected driver! Download address: http: / / dev mysql. com/downloads/connector net /, after installation, add references in the project Mysql. Data. dll;
2. Configure the connection string:
In web. config
<configuration
<connectionStrings>
<addname="MysqlConnection"connectionString="server=localhost;userid=root;password=123456;database=test1;"/>
</connectionStrings>
</configuration
In the background code:
string sqlstring = System.Configuration.ConfigurationManager.ConnectionStrings["MysqlConnection"].ConnectionString;
MySqlConnection myconn=new MySqlConnection(sqlstring);
myconn.Open();