Question Problems with Insert MySql db

gate7cy

Well-known member
Joined
May 11, 2009
Messages
119
Programming Experience
3-5
I am trying to to an insert query on my MySql db using VS 2008/VB. I have this query:

VB.NET:
Insert into allservices  StartDate....) values ('" & Me.datesched.Value & "', ....)

When I use the single and double quotes, as it is above , I get this error:

Incorrect date value '21/10/2009' for column StartDate at row 1

when I remove the single quotes and have only the double ones I get a completely different thing. The date inserted to the database is 01/01/0001. Even if my datetimepicker has a min and max date. Anyone knows something on this issue? Also if someone has any good links on using mysql with vb.net would be very helpfull to share.. Thanks for your effort and time..

cheers guys and gals
 
I have resolved this issue by formatting the date as so:

Dim boughtdate1 As String = Format(Me.boughtDate.Value, "yyyy/MM/dd")

In this way I do not care about the individual system`s regional settings and also it is accepted by MySql
 
gate7cy said:
I have resolved this issue by formatting the date as so:
You should use parameters in your queries, that way you can supply Date values and let the provider handle underling transport to db. This will also guard you against possible injection attacks and in general give better code and db performance.
 
Back
Top