Re: INSERT Command Problems
Try this.
Code:
Using meldingcmd As OleDbCommand = New OleDbCommand
Make_con()
With meldingcmd
.Parameters.Clear()
.Connection = con
.CommandText = "INSERT INTO Meldingen (Weg_ID,Onderdeel,Dringendheid,Beginlat,Beginlong,Eindlat,Eindlong,Afstand,Opmerkingen,Datum) VALUES (@p1,p2,p3,p4,p5,p6,p7,p8,p9,p10);"
.Parameters.AddWithValue("@p1", Convert.ToInt32(current_weg_Id))
.Parameters.AddWithValue("@p2", Onderdeel_CBX.Text)
.Parameters.AddWithValue("@p3", Dringendheid_CBX.Text)
.Parameters.AddWithValue("@p4", Convert.ToDecimal(BeginLAT_T.Text))
.Parameters.AddWithValue("@p5", Convert.ToDecimal(BeginLONG_T.Text))
.Parameters.AddWithValue("@p6", Convert.ToDecimal(EindLAT_T.Text))
.Parameters.AddWithValue("@p7", Convert.ToDecimal(EindLONG_T.Text))
.Parameters.AddWithValue("@p8", Convert.ToDecimal(Afstand_T.Text))
.Parameters.AddWithValue("@p9", Melding_opmerking_T.Text)
.Parameters.AddWithValue("@p10", Date.Now())
.ExecuteNonQuery()
End With
con.Close()
End Using
Re: INSERT Command Problems
Also, you might not need to use Convert.ToDecimal, because when you paramterize your queries, they get converted to the right data type automatically.
Re: INSERT Command Problems
Re: INSERT Command Problems
Toph,
It keeps giving the same Error :(
Re: INSERT Command Problems
Oops, add @p1, @p2, @p3 and so on. I forgot to include the @ sign in the Insert Statement
Re: INSERT Command Problems
VALUES (@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10);"
Re: INSERT Command Problems
It's something with the Date input that is wrong...the rest he saves good...
Re: INSERT Command Problems
Found the problem...I should have put
Code:
.Parameters.AddWithValue("@p10", DateTime.Parse(Date.Now()))
This works.
Anyway thanks :-)
Re: INSERT Command Problems
No problem :), I knew you'd work something out