本文介绍了无法纠正错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public void Add_scheduled(object sender, EventArgs e)
{
String sql;
sql = "insert into dbo.b_schedule";
sql = sql + "(sdate,scost,sremark,ano)";
sql = sql + "values(Convert(date,'" + adddate.Text + "',103),";
sql = sql + Convert.ToDouble(Mcost.Text) + ",";
sql = sql + "'" + Mremark.Text + "',";
sql = sql + uano.Text + ")";
c.executeqry(sql);
adddate.Text = string.Empty;
Mcost.Text = string.Empty;
Mremark.Text = string.Empty;
uano.Text = string.Empty;
Response.Redirect("BQS.aspx");
}
public void Add_unscheduled(object sender, EventArgs e)
{
String sql;
sql = "insert into dbo.b_unschedule";
sql = sql + "(udate,ucost,d_date,d_reason,uremark,ano)";
sql = sql + "values(Convert(date,'" + mdate.Text + "',103),";
sql = sql + Convert.ToDouble(ucost.Text) + ",";
sql = sql + "'" + ureason.Text + "',";
sql = sql + "'" + udamage.Text + "',";
sql = sql + "'" + uremark.Text + "',";
sql = sql + uano.Text + ")";
c.executeqry(sql);
mdate.Text = string.Empty;
ucost.Text = string.Empty;
ureason.Text = string.Empty;
udamage.Text = string.Empty;
uremark.Text = string.Empty;
uano.Text = string.Empty;
Response.Redirect("BQS.aspx");
}
推荐答案
public void Add_scheduled(object sender, EventArgs e)
{
String sql;
String str = "server=abc;uid=sa;pwd=sa;initial catalog=master"; // define your server credentials
SqlConnection cn = new SqlConnection(str);
SqlCommand cmd;
sql = "insert into dbo.b_schedule";
sql = sql + "(sdate,scost,sremark,ano)";
sql = sql + "values(" + adddate.Text + "',";
sql = sql + Convert.ToDouble(Mcost.Text) + ",";
sql = sql + "'" + Mremark.Text + "',";
sql = sql + uano.Text + ")";
cmd = new SqlCommand(sql,cn);
cn.Open();
c.executeqry(sql);
cn.Close();
adddate.Text = string.Empty;
Mcost.Text = string.Empty;
Mremark.Text = string.Empty;
uano.Text = string.Empty;
Response.Redirect("BQS.aspx");
}
这篇关于无法纠正错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!