这些是我想要发送到数据库的值
private void radButton1_Click(object sender, EventArgs e)
{
string constring = "datasource=localhost;port=3306;username=root;";
string Query = "insert into rhms.reservation(no_table)values('" + this.comboBox1.SelectAll() + "');";
MySqlConnection condatabase = new MySqlConnection(constring);
MySqlCommand cmd = new MySqlCommand(Query, condatabase);
MySqlDataReader myread;
try
{
condatabase.Open();
myread = cmd.ExecuteReader();
MessageBox.Show("saved");
this.Refresh();
while (myread.Read())
{
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
答案 0 :(得分:0)
您需要在查询字符串中设置正确的信息。现在它不正确。数据必须用逗号分隔:
string Query = "insert into rhms.reservation(no_table) values " + this.comboBox1.Items
.Select(p=>string.Format("({0})",p.ToString()))
.Aggregate((p1,p2)=>p1 + "," + p2) + ";"