我尝试在选择值时编写代码,状态会自动更改,但是当我将值与 DB 链接时,它会显示错误,请告知,谢谢。
private void SelectStatus()
{
WMWTLocator.Items.Clear();
WMWTStatus.Text = "";
string selectSQL = "SELECT STATUS_ID_SYS,STATUS_ID,STATUS_DESC FROM [AcmkIMS].[dbo].[IMS_STATUS_ID] WHERE STATUS_ID_SYS = 'WM' AND STATUS_ID = '" + WMWTLocator.SelectedItem.Value + "' ";
try
{
con.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
ListItem newItem = new ListItem();
WMWTStatus.Text = reader["STATUS_DESC"].ToString();
newItem.Text = reader["STATUS_ID"].ToString();
newItem.Value = reader["STATUS_ID"].ToString();
WMWTLocator.Items.Add(newItem);
}
reader.Close();
}
catch (Exception err)
{
lblResults.Text = "Error reading list of Transaction Status. ";
lblResults.Text += err.Message;
}
finally
{
con.Close();
}
}