我试图验证我的程序是否未指向空值,或者即使它已连接到数据库,但事实并非如此。我确保变量和列具有相同的类型,但仍然相同。
SqlConnection conexao = new SqlConnection(conexao2);
try
{
switch (File.ReadLines(backingFile).ElementAt(5)) \\gets the database that needs to be updated
{
case "SAGE":
{
SqlCommand comando = new SqlCommand
("UPDATE ItemNames SET Description='" + textBox2.Text + "' WHERE ShortDescription='" + descricao + "'", conexao);\\ here is where the program should update the description accordingly to the inserted text in the text box
comando.Connection = conexao;
conexao.Open();
comando.ExecuteNonQuery();
conexao.Close();
break;
}
catch (Exception er)
{
MessageBox.Show(er.Message);
}
输出:“指定的参数超出了有效数字范围,参数名称:索引”