B
Bajtitou
Guest
Hi,
I am using Ms-Access Data Base, OledbConnection.
I get a Message about Data Type Mismatch When I run This Code,
So Thank you very Much for your Help And Best Regards.
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Try
con = New OleDbConnection(cs)
con.Open()
Dim cb As String = "insert into Ponte1(PID,CoupleID,Cage,Race,Enponte,Couvant,Eclos,datedeponte,datedecouvaison,datedemirage,datedéclosion) VALUES (" & txtID.Text & ",@d1,@d2,@d3,@d4,@d5,@d6)"
cmd = New OleDbCommand(cb)
cmd.Parameters.AddWithValue("@d1", txtCoupleID.Text)
cmd.Parameters.AddWithValue("@d2", CmbCage.Text)
cmd.Parameters.AddWithValue("@d3", CmbRace.Text)
cmd.Parameters.AddWithValue("@d4", TxtenPonte.Text)
cmd.Parameters.AddWithValue("@d5", TxtCouvant.Text)
cmd.Parameters.AddWithValue("@d6", txtEclos.Text)
cmd.Parameters.Add("@d18", OleDbType.Date, 30, "DateDePonte").Value = DTPicker1.Value.Date
cmd.Parameters.Add("@d19", OleDbType.Date, 30, "DateDeCouvaison").Value = DTPicker1.Value.Date.AddDays(4)
cmd.Parameters.Add("@d20", OleDbType.Date, 30, "DateDeMirage").Value = DTPicker1.Value.Date.AddDays(9)
cmd.Parameters.Add("@d21", OleDbType.Date, 30, "DateDéclosion").Value = DTPicker1.Value.Date.AddDays(17)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
MessageBox.Show("Successfully saved", " Ponte1 Record", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
end sub
Continue reading...
I am using Ms-Access Data Base, OledbConnection.
I get a Message about Data Type Mismatch When I run This Code,
So Thank you very Much for your Help And Best Regards.
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Try
con = New OleDbConnection(cs)
con.Open()
Dim cb As String = "insert into Ponte1(PID,CoupleID,Cage,Race,Enponte,Couvant,Eclos,datedeponte,datedecouvaison,datedemirage,datedéclosion) VALUES (" & txtID.Text & ",@d1,@d2,@d3,@d4,@d5,@d6)"
cmd = New OleDbCommand(cb)
cmd.Parameters.AddWithValue("@d1", txtCoupleID.Text)
cmd.Parameters.AddWithValue("@d2", CmbCage.Text)
cmd.Parameters.AddWithValue("@d3", CmbRace.Text)
cmd.Parameters.AddWithValue("@d4", TxtenPonte.Text)
cmd.Parameters.AddWithValue("@d5", TxtCouvant.Text)
cmd.Parameters.AddWithValue("@d6", txtEclos.Text)
cmd.Parameters.Add("@d18", OleDbType.Date, 30, "DateDePonte").Value = DTPicker1.Value.Date
cmd.Parameters.Add("@d19", OleDbType.Date, 30, "DateDeCouvaison").Value = DTPicker1.Value.Date.AddDays(4)
cmd.Parameters.Add("@d20", OleDbType.Date, 30, "DateDeMirage").Value = DTPicker1.Value.Date.AddDays(9)
cmd.Parameters.Add("@d21", OleDbType.Date, 30, "DateDéclosion").Value = DTPicker1.Value.Date.AddDays(17)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
MessageBox.Show("Successfully saved", " Ponte1 Record", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
end sub
Continue reading...