SqlConnection myCon;
myCon = new SqlConnection("data source=localhost;initial catalog=hotel;user id=sa;password=123");
string sql2 = "update room set status = '入住' where roomId = '" + roomId + "'";
SqlCommand myCom = new SqlCommand(sql2, myCon);
myCon.Open();
SqlDataReader Reader;
Reader = myCom.ExecuteReader();status数据类型为VARCHAR,不清楚为什么会错误
myCon = new SqlConnection("data source=localhost;initial catalog=hotel;user id=sa;password=123");
string sql2 = "update room set status = '入住' where roomId = '" + roomId + "'";
SqlCommand myCom = new SqlCommand(sql2, myCon);
myCon.Open();
SqlDataReader Reader;
Reader = myCom.ExecuteReader();status数据类型为VARCHAR,不清楚为什么会错误
解决方案 »
- C#中怎样实现C中的typedef的功能呢?
- 同一个网站的不同url,在相同的代码块中获取html页面,有的乱码有的正常。求助!!!
- 如何进行TCP/IP编程?(C#语言)
- Excel 转换成 image
- VB代码如何转换C#代码!?可以转吗?
- 控制台程序中如何实现键盘输入一个字符就返回?不用像Console.Read()那样要等到回车
- 怎样引用第三方的dll
- 急!!! Window 中的DataGrid如何分页
- 如何用Visual C#遍历网络文件
- Windows系统如何修改tcp/ip协议的timeout时间?
- C# talControl 你可能一直没有注意到的问题
- sqlcommand?
按照2楼说的,改为ExecuteNoQuery,
string sql2 = string.Format("update room set status = '入住' where roomId = '{0}' ", roomId);
SqlCommand myCom = new SqlCommand(sql2, myCon);
myCon.Open();
int affectrows=myCom.ExecuteNonQuery();
应该先用c#进行转换,
int status = 0;
if(txtStatus.text == '入住') status = 1
else status = 0然后再用
string sql2 = "update room set status = " + status + " where roomId = '" + roomId + "'";
有错的话就检查一下语句
没错的话可能就是如2楼的改法了