如何更改多个房间的房间状态? [英] How to change room status of multiple rooms?

查看:104
本文介绍了如何更改多个房间的房间状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的代码来更改房间状态。它工作正常,因为直到那时我只需更改单人房间状态。



I am using code like below to change room status. It was working fine because till that time i had to change only single room status.

String sqlr = "update roominformation set status = '0' where roomno = '" + txt_roomno.Text + "'";
new OleDbCommand(sqlr, sr, trans).ExecuteNonQuery();





现在我在单个文本框(txt_roomno)中有多个房间,如Single-101,Single-102,Single-103。在此之前,我在文本框中只有一个房间,如Single-101,所以更新时没有问题。



我现在的问题是如何更改单个文本框中的多个房间号码的状态。



这将是第一个更改Single-101的状态,然后是Single-102,在Single-103之后。



我不知道如何完成这项任务..



请帮助。



Now i have multiple rooms in the single text box (txt_roomno) like Single-101,Single-102,Single-103. Before this i have only one room in the text box like Single-101,so there is no problem while updating this.

My Question is now how can i change the status of multiple room numbers from single text box.

It will be like First change the status of Single-101, then Single-102, after that Single-103.

I dont know how to achieve this task..

Please help.

推荐答案

以这种方式实现:

implement this way:
string text = txt_roomno.Text;
string[] arrRoomNos = text.Split(',');

string roomNosCSV = string.Empty;
foreach (string room in arrRoomNos)
{
    if (roomNosCSV != string.Empty)
        roomNosCSV += ",";

    roomNosCSV += "'" + room.Trim() + "'";
}

String sqlr = "update roominformation set status = '0' where roomno in (" + roomNosCSV + ")";
new OleDbCommand(sqlr, sr, trans).ExecuteNonQuery();


Hello Harpreet,



以逗号格式分隔的单个变量中的多个房间号。

例如



Hello Harpreet,

Take the multiple room number in single variable separated by comma format.
E.g.

String txt_roomno.Text= 'Single-101,Single-102,Single-103' ;





编写你的SQL查询如下





And write your SQL query as below

String sqlr = "update roominformation set status ='0' where roomno in '" + txt_roomno.Text + "'";


这篇关于如何更改多个房间的房间状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆