‘需要参数@p1,但未提供参数
try
{
conn.Open();
SqlCommand cmd = new SqlCommand("select ID号 from 初始化扫描", conn);
SqlDataReader r = cmd.ExecuteReader();
int i = 0;
布草种类comboBox.SelectedIndexChanged += new EventHandler(布草种类comboBox_SelectedIndexChanged);
while (r.Read())
{
string str = r[0].ToString();
初始化DataGridView.Rows.Add(str.Length);
初始化DataGridView.Rows[i].Cells[0].Value = str;
adapter.InsertCommand.CommandText = "INSERT INTO 布草初始化列表(ID号,布草属性,洗涤次数)VALUES('"+str+"','"+布草种类comboBox.SelectedItem+"','1')";
i++;
try
{
if (conn1.State == ConnectionState.Closed)
{
conn1.Open();
}
adapter.InsertCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn1.Close();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}