问题描述
SqlConnection objCon = new SqlConnection(@Data Source = MIS-PC; Initial Catalog = projecthotel; Integrated Security = True);
SqlCommand objCmd = new SqlCommand();
objCmd.Connection = objCon;
string query =insert into Reservation values('+ textBox1.Text + ','+ comboBox2.Text +','+ textBox4.Text +','+ textBox6.Text +','+ textBox7.Text +','+ textBox15.Text + ','+ comboBox7.Text +','+ comboBox8.Text +','+ comboBox9.Text +','+ textBox25.Text +','+ textBox17.Text + ','+ textBox18.Text +','+ textBox20.Text +','+ textBox21.Text +');
objCmd.CommandText = query;
objCon.Open();
int j = objCmd.ExecuteNonQuery();
if(j> 0)
{
MessageBox.Show(Record Inserted,www.codingresolved.com);
dataGridView3.Rows.Clear();
}
objCon.Close();
Form1 form1 = new Form1();
form1.Show();
}
SqlConnection objCon = new SqlConnection(@"Data Source=MIS-PC;Initial Catalog=projecthotel;Integrated Security=True");
SqlCommand objCmd = new SqlCommand();
objCmd.Connection = objCon;
string query = "insert into Reservation values('" + textBox1.Text + "', '" + comboBox2.Text + "','" + textBox4.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox15.Text + "','" + comboBox7.Text + "','" + comboBox8.Text + "','" + comboBox9.Text + "','" + textBox25.Text + "','" + textBox17.Text + "','" + textBox18.Text + "','" + textBox20.Text + "','" + textBox21.Text + "')";
objCmd.CommandText = query;
objCon.Open();
int j = objCmd.ExecuteNonQuery();
if (j > 0)
{
MessageBox.Show("Record Inserted","www.codingresolved.com");
dataGridView3.Rows.Clear();
}
objCon.Close();
Form1 form1 = new Form1();
form1.Show();
}
推荐答案
这篇关于dridview没有显示任何数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!