sql字符串拼接问题
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行影响,数据被添加求帮助啊!
...全文
相关推荐
MyBatis 动态拼接Sql字符串的问题
MyBatis的动态SQL,解决了SQL字符串拼接的痛苦。下文分步骤给大家详细介绍了MyBatis 动态拼接Sql字符串的问题,非常不错,感兴趣的朋友一起看下吧
深入讲解SQL中的字符串拼接
主要介绍了关于SQL中字符串拼接的相关资料,其中包括了数字 + 字符串、数字 + 数字、字符串 + 字符串以及使用CAST和CONVERT函数进行类型转换等,需要的朋友可以参考借鉴,下面来一起看看吧。
sql的封装,不需要使用StringBuffer进行字符串拼接
sql的封装,不需要使用StringBuffer进行字符串拼接 直接使用对象封装
oracle中将列拼接字段函数
select WMSYS.WM_CONCAT(contractid) from fin_cbs_manager select contractid from fin_cbs_manager
SQL2JAVA-java字段串代码拼接小工具
一款方便将java与sql语句互相转换的小工具,在日常工作开发中,非常实用,f方便写字符串拼接的语句,常用选项是String和StringBuffer


