急:请高手指点,多谢!
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();
}