sql字符串拼接问题

llc961478 llc961478 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
    protected void lkupdzlxx_Click(object sender, EventArgs e)
{
try
{
sqlcon scn = new sqlcon();
scn.con();
scn.setinsert("治疗信息(ID, 治疗方式, 剂量, 计划, 实际, 开始时间, 结束时间,结束提醒)",
"'" + txtid.Text + "'," + "'" + txt1zhiliaofangshi.Text + "'," + "'" + txt2jiliang.Text + "'," +
"'" + txt3jihua.Text + "',"
+ "'" + txt4shiji.Text + "'," +
"'" + txt5starttime.Text + "'," +
"'" + txt6endtime.Text + "'," +
"'" + txt7remindtime.Text + "'");
Response.Write("success");
}
catch { Response.Write("false"); }
}


public void setinsert(string columnname,string insertstring)
{
sda.InsertCommand = new SqlCommand( "insert into " + columnname + " values (" + insertstring + ")");
}


断点调试后 sda中InsertCommand为:
"insert into 治疗信息(ID, 治疗方式, 剂量, 计划, 实际, 开始时间, 结束时间,结束提醒)
values ('2','q','q','q','q','2013-11-5 09:31:16',
'2013-11-5 10:31:16','2013-11-5 10:26:16')"、
//此时数据库中无生成内容。
//将该语句复制到sql查询中得到1行影响,数据被添加


求帮助啊!
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
llc961478
.NET社区 62,274 成员 668,968 内容