我使用填充了表格名称的组合框。当我发出插入命令并通过获取组合框的值来确定表名时,它不起作用
private void Form2_Load(object sender, EventArgs e)
{
Conn.Open();
foreach (DataRow dr in dt.Rows)
{
comboBox1.Items.Add(dr["TABLE_NAME"].ToString());
}
Conn.Close();
}
//cmd = new SqlCommand("insert into dbo."+ comboBox1.SelectedItems.ToString() +"(Phone, Email, Address) values('" + txt1.Text + "','" + txt2.Text + "','" + txt3.Text + "')", Conn);