C#中的语句格式问题

gpz_dalian 2006-10-27 03:34:26
如果想将如下语句:
string sqlInsert = @"insert into HTPOrderTransaction values("
+ "'" + storeCode + "'" + ","
+ "'" + terminalID + "'" + ","
+ "'" + sequenceNo + "'" + ","
+ "'" + employeeCode + "'" + ","
+ "'" + scheduleDate + "'" + ","
+ "'" + barCode + "'" + ","
+ "'" + quantity + "'" + ","
+ "'" + entryDate + "'" + ","
+ "'" + createDate + "'" + ","
+ "'" + amendDate + "'" + ")";
改写成如下格式:
string sqlSelect = string.Format(@"select StoreCode,TerminalID,SequenceNo from
HTPOrderTransaction where StoreCode = {0}
and TerminalID = '{1}' and SequenceNo = {2}",storeCode,terminalID,sequenceNo);
请教:应该怎么写呢?

...全文
140 5 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
kaoziji 2006-10-27
  • 打赏
  • 举报
回复
我觉得使用 parameter.add 设置SQL中的参数,可以提高数据库端的效率
早起晚睡 2006-10-27
  • 打赏
  • 举报
回复
收藏
gpz_dalian 2006-10-27
  • 打赏
  • 举报
回复
多谢了!很好用啊
icehawk 2006-10-27
  • 打赏
  • 举报
回复

string sqlInsert = string.Format("insert into HTPOrderTransaction values('{0}','{1}','{2}','{3}','{4}','5}','{6}','{7}','{8}','{9}')",storeID,terminalID,sequenceNo,employeeCode,scheduleDate ,barCode ,quantity ,entryDate ,createDate , amendDate );


Robert_Wang1983 2006-10-27
  • 打赏
  • 举报
回复
string sqlInsert = string.Format("insert into HTPOrderTransaction values('{0}','{1}')",storeID,terminalID);
相关推荐
发帖
C#

10.8w+

社区成员

.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
帖子事件
创建了帖子
2006-10-27 03:34
社区公告

让您成为最强悍的C#开发者