VS2015如何连接mySQL数据库图文
string str = "Server=127.0.0.1;User> MySqlConnection con = new MySqlConnection(str);//实例化链接con.Open();//开启连接
string strcmd = "select * from user";
MySqlCommand cmd = new MySqlCommand(strcmd, con);
MySqlDataAdapter ada = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
ada.Fill(ds);//查询结果填充数据集
dataGridView1.DataSource = ds.Tables;
con.Close();//关闭连接 感谢楼主分享···············
页:
[1]