|
 |
|
Insert 2 tables ครับ ช่วยด้วย .. บันทึกข้อมูลเรียบร้อย .. มัน Error ตรงนี้อ่ะคับ |
|
 |
|
|
 |
 |
|
string con = connection.con;
SqlConnection cn = new SqlConnection(con);
cn.Open();
String sql = "INSERT INTO Violator VALUES(@Vio_allowno, @Vio_name, @Vio_cardno, @Vio_carno, @Vio_cartype, @Vio_carlogo, @Vio_carprovince, @Vio_allowtype)";
SqlCommand cmd = new SqlCommand(sql, cn);
cmd.Parameters.AddWithValue("@Vio_allowno", allowno.Text);
cmd.Parameters.AddWithValue("@Vio_name", namevio.Text);
cmd.Parameters.AddWithValue("@Vio_cardno", cardno.Text);
cmd.Parameters.AddWithValue("@Vio_carno", carno.Text);
cmd.Parameters.AddWithValue("@Vio_cartype", cartype.Text);
cmd.Parameters.AddWithValue("@Vio_carlogo", carlogo.Text);
cmd.Parameters.AddWithValue("@Vio_carprovince", carprovince.Text);
cmd.Parameters.AddWithValue("@Vio_allowtype", allowtype.Text);
cmd.ExecuteNonQuery();
String sql2 = "SELECT Vio_allowno FROM Violator WHERE Vio_allowno = '" + allowno.Text + "'";
SqlCommand cmd2 = new SqlCommand(sql2, cn);
SqlDataAdapter adapter = new SqlDataAdapter(cmd2);
DataSet ds = new DataSet();
adapter.Fill(ds, "Vio_allowno");
String sql3 = "INSERT INTO Orderbill VALUES(@Order_date, @Order_time, @Order_address, @Law_id, @alreadypaid, @Vio_allowno)";
SqlCommand cmd3 = new SqlCommand(sql3, cn);
cmd3.Parameters.AddWithValue("@Order_date", DateTime.Now.ToString("dd/MM/yyyy"));
cmd3.Parameters.AddWithValue("@Order_time", DateTime.Now.ToString("hh:mm:ss"));
cmd3.Parameters.AddWithValue("@Order_address", addressbox.Text);
cmd3.Parameters.AddWithValue("@Law_id", comboBox5.SelectedValue);
cmd3.Parameters.AddWithValue("@alreadypaid", "ค้างชำระ");
cmd3.Parameters.AddWithValue("@Vio_allowno", ds); <------- มัน Error ตรงนี้อ่ะคับ
cmd3.ExecuteNonQuery();
cn.Close();
Cursor.Current = Cursors.Default;
MessageBox.Show("บันทึกข้อมูลเรียบร้อย", "Successful Data");
confirm f = new confirm();
f.Show();
this.Close();
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-03-03 12:44:44 |
By :
วุดดี้ |
View :
1322 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มี Message Error หรือเปล่าครับ แล้ว ds คืออะไร
|
 |
 |
 |
 |
Date :
2010-03-03 13:01:48 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ่อ มัน error ที่ cmd3.Parameters.AddWithValue("@Vio_allowno", ds);
No mapping exists from DbType {0} to a known {1}.
*คับ
|
 |
 |
 |
 |
Date :
2010-03-03 13:32:54 |
By :
วุดดี้ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|