1.增
string constr="server=localhost;User Id=root;password=123456;Database=soft123";
MySqlConnection mycon=new MySqlConnection(constr);
mycon.Open();
MySqlCommand mycmd = new MySqlCommand("insert into soft_control(soft_name,password,url) values('qqzone','123456','https://login.taobao.com/member/login.jhtml')", mycon);
if (mycmd.ExecuteNonQuery()>0)
{
MessageBox.Show("数据插入成功!");
}
2.删
3.改
4.查
MySqlConnection mycon=new MySqlConnection(constr);
mycon.Open();
MySqlCommand mycmd = new MySqlCommand("select * from soft_control where soft_name='qqzone'",mycon);
MySqlDataReader dr = mycmd.ExecuteReader();
//将结果赋值到了dr,下面开始输出
int i=0;
while (dr.Read())
{
MessageBox.Show(dr[i++].ToString());
}
mycon.Close();