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

来源:百度知道 编辑:UC知道 时间:2024/06/30 04:59:08
举个例子,加以说明,不胜感激!!!!

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
{<