急:请高手指点,多谢!

drue 2003-10-16 10:48:21
public bool LottSale(string LottNo, int AccNo)
{
SqlConnection MyCon;
MyCon = new SqlConnection();
MyCon.ConnectionString = "user id=student;password=student;initial catalog=WebBank;data source=127.0.0.1;Connect Timeout=30";

SqlCommand MyCmd1;
string UpdateCmd;
//就下面这一句不懂,编译通过了,可我知道我肯定把格式能错了。不知道该怎样应用SQL命令。
UpdateCmd = "update AccountInfo set CloseBalance=CloseBalance-2,TotalDebits=TotalCredits+2 where AccountNo=" + AccNo;
MyCmd1 = new SqlCommand(UpdateCmd, MyCon);

SqlCommand MyCmd2;
string InsertCmd;
InsertCmd = "insert into LotteryInfo (LotteryType, LotteryNumber) values ('NSW', " + LottNo); //这里也是不明白该怎么写
MyCmd2 = new SqlCommand(InsertCmd, MyCon);

try
{
MyCmd1.ExecuteNonQuery();
MyCmd2.ExecuteNonQuery();
return true;
}
catch (Exception SqlXpt)
{
return false;
}
MyCmd1.Connection.Close();
}
...全文
32 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
wjhs 2003-10-17
  • 打赏
  • 举报
回复
过去啦就行,

110,500

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

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

试试用AI创作助手写篇文章吧