รบกวนพี่ๆ ช่วย ดู error ให้หน่อยค่ะ The variable name has already been declared. Variable names must be unique within a query batch or stored procedure
Code (C#)
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
cmd.Connection = conn;
cmd.CommandText = "INSERT INTO tblRepair (RpID, BdID, RmID, DvID, RpDetail, RpRequest)";
cmd.CommandText += "VALUES ('Rp-' + REPLICATE('0', 5 - LEN(IDENT_CURRENT('tblRepair'))) + CONVERT(nvarchar(50), IDENT_CURRENT('tblRepair')) ,@BdID, @RmID, @DvID, @RpDetail, @RpRequest)";
cmd.Parameters.Add("@BdID", SqlDbType.NVarChar).Value = ddlBuilding.SelectedValue.ToString();
cmd.Parameters.Add("@RmID", SqlDbType.NVarChar).Value = ddlRoom.SelectedValue.ToString();
cmd.Parameters.Add("@RpDetail", SqlDbType.NVarChar).Value = txtRpDetail.Text.Trim();
cmd.Parameters.Add("@RpRequest", SqlDbType.DateTime).Value = DateTime.Now;
//cmd.Parameters.Add("@UsID", SqlDbType.NVarChar).Value = ddlUser.SelectedValue.ToString();
int i;
for (i = 0; i <= this.CheckBoxList.Items.Count - 1; i++)
{
if (CheckBoxList.Items[i].Selected == true)
{
cmd.Parameters.Add("@DvID", SqlDbType.NVarChar).Value = CheckBoxList.Items[i].Value;
}
else if (CheckBox.Checked == true)
{
cmd.Parameters.Add("@DvID", SqlDbType.NVarChar).Value = txtother.Text.Trim();
}
}
Tag : C#
ประวัติการแก้ไข 2017-05-16 21:32:26
Date :
2017-05-16 21:21:53
By :
kamonwanarin
View :
1406
Reply :
3
mr.win ขอบคุณค่ะ
Date :
2017-05-18 00:04:14
By :
kamonwanarin
Date :
2017-05-18 09:05:21
By :
mr.win
Load balance : Server 03