配列を介してデータベースの値を更新していますが、配列の最後の値のみをすべての行に更新しています。私は何が間違っているのですか?
.csファイル内
BL_HotelDetails hd1 = new BL_HotelDetails();
string[] strResult = strObj.Split(',');
hd1.updateintoRoomNames(hid, strResult);
Bussinessロジックレイヤー内
public void updateintoRoomNames(int hid, string[] strResult)
{
DA_HotelDetails hd2 = new DA_HotelDetails();
hd2.updateintoRommNamesDA(hid,strResult);
}
データアクセス層内
public void updateintoRommNamesDA(int hid, string[] strResult)
{
foreach (string s in strResult)
{
Connection concls = new Connection();
SqlCommand cmd = new SqlCommand();
string instr = "update tblRoomNames set roomnames='" + s + "' where hid=" + hid + "";
concls.opencon();
cmd.CommandText = instr;
concls.executenonquery(cmd);
concls.closecon();
}
}