string con = "server=127.0.0.1;user id=root;password=;database=db";
MySqlConnection sqlconn = new MySqlConnection(con);
sqlconn.Open();
string sql = "select * from users where NAME=?NAME;";
MySqlCommand cmd=new MySqlCommand (sql,sqlconn);
cmd.Parameters.Add("?NAME", MySqlDbType.VarChar).Value ="张山"; MySqlDataAdapter myda = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
myda.Fill(dt);
myda.Dispose();
sqlconn.Dispose();
sqlconn.Close();
dataGridView1.DataSource = dt;
users表ID bigint
name varchar(500);
米脂
慕少森
相关分类