在VS2005中完成对sql数据库的插入,删除、修改、查询功能

举个例子,加以说明,不胜感激!!!!
2024-12-19 23:06:40
推荐回答(2个)
回答1:

conn = Common.DBHelper.DataConn();
string sql = string.Format("insert into tb_tel([UserName],[UserSex],[UserTel]) values('{0}','{1}','{2}')", txtName.Text.Trim(), cboSex.Text, txtPhone.Text);
conn.Open();
OleDbCommand cmd = new OleDbCommand(sql, conn);
int count = cmd.ExecuteNonQuery();
if (count <= 0)
{
MessageBox.Show("添加不成功!");
}
else
{
MessageBox.Show("添加用户成功!");
txtName.Text="";
txtPhone.Text = "";

}
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}
finally
{
if (conn!=null && conn.State==ConnectionState.Open)
{
conn.Close();
}
}
看不懂找我!

回答2:

一下子把增删查改都问完了,就不舍得给点分数?