没有提示错误,点击提交后数据库没有写入数据?是什么原因? 50
stringstr_cnn="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=";stringstr_sourcefile="~/...
string str_cnn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
string str_sourcefile = "~/App_Data\\Data.mdb";
OleDbConnection cnn;
OleDbCommand cmd;
OleDbDataReader datar;
string str_sql;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
string str_conn = str_cnn + MapPath(str_sourcefile);
cnn = new OleDbConnection(str_conn);
cnn.Open();
str_sql = makesql();
cmd = new OleDbCommand(str_sql, cnn);
cmd.ExecuteNonQuery();
cnn.Close();
lbl.Text = "添加成功!";
}
protected string makesql()
{
string _result = "";
string _seid, _arid, _name, _tiid, _mr1, _mr2, _position, _employ, _infor;
_name = uni1.Text;
_seid = uni2.Text;
_arid = uni3.Text;
_tiid = uni4.Text;
_position = uni6.Text;
_employ = uni7.Text;
_infor = uni8.Text;
//if (uni5.Checked == true)
//{
// _mr1 = "1";
// if (uni52.Checked == true)
// {
// _mr2 = "2";
// }
// else
// {
// _mr2 = "0";
// }
//}
//else
//{
// if (uni52.Checked == true)
// {
// _mr1 = "2";
// }
// else
// {
// }
// _mr1 = "0";
// _mr2 = "0";
//}
_result = "INSERT INTO T_ptUnit(pu_seid,pu_arid,pu_name,pu_tiid,pu_mr1,pu_mr2,pu_mr3,pu_mr4,pu_position,pu_employ,pu_infor,pu_img,pu_album,pu_enable,pu_push) values ('" + _seid + "','" + _arid + "','" + _name + "','" + _tiid + "',1,2,0,0,'" + _position + "','" + _employ + "','" + _infor + "',15,15,true,true)";
return _result;
}
} 展开
string str_sourcefile = "~/App_Data\\Data.mdb";
OleDbConnection cnn;
OleDbCommand cmd;
OleDbDataReader datar;
string str_sql;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
string str_conn = str_cnn + MapPath(str_sourcefile);
cnn = new OleDbConnection(str_conn);
cnn.Open();
str_sql = makesql();
cmd = new OleDbCommand(str_sql, cnn);
cmd.ExecuteNonQuery();
cnn.Close();
lbl.Text = "添加成功!";
}
protected string makesql()
{
string _result = "";
string _seid, _arid, _name, _tiid, _mr1, _mr2, _position, _employ, _infor;
_name = uni1.Text;
_seid = uni2.Text;
_arid = uni3.Text;
_tiid = uni4.Text;
_position = uni6.Text;
_employ = uni7.Text;
_infor = uni8.Text;
//if (uni5.Checked == true)
//{
// _mr1 = "1";
// if (uni52.Checked == true)
// {
// _mr2 = "2";
// }
// else
// {
// _mr2 = "0";
// }
//}
//else
//{
// if (uni52.Checked == true)
// {
// _mr1 = "2";
// }
// else
// {
// }
// _mr1 = "0";
// _mr2 = "0";
//}
_result = "INSERT INTO T_ptUnit(pu_seid,pu_arid,pu_name,pu_tiid,pu_mr1,pu_mr2,pu_mr3,pu_mr4,pu_position,pu_employ,pu_infor,pu_img,pu_album,pu_enable,pu_push) values ('" + _seid + "','" + _arid + "','" + _name + "','" + _tiid + "',1,2,0,0,'" + _position + "','" + _employ + "','" + _infor + "',15,15,true,true)";
return _result;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询