By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,067 Members | 1,849 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,067 IT Pros & Developers. It's quick & easy.

error on datagridview date field using mysql and vb2005

P: 13
Well, the app im working on makes an error when trying to populate a datagridview when the source contains date field. Any solution to my problem?


dgvInvoices.DataSource = richdb.getTableData("Select invoiceno,duedate as string from invoice Where IsCleared = '0' and duedate <= '" & convert.tomysqldatenow & "'")

Error: Unable to convert MySQL date/time value to System.DateTime
Feb 1 '08 #1
Share this Question
Share on Google+
4 Replies


daniel aristidou
100+
P: 491
Well, the app im working on makes an error when trying to populate a datagridview when the source contains date field. Any solution to my problem?
Error: Unable to convert MySQL date/time value to System.DateTime
Try this....
Expand|Select|Wrap|Line Numbers
  1. Bindingsource.filter = "Iscleared = '0'" "and duedate <= '" & now & "'"
Feb 1 '08 #2

P: 13
Thanks but a complete noob here. :)

Where should i place the bindingsource.filter?

Will it allow me to display mysql dates on the datagridview w/o the error?
Feb 1 '08 #3

daniel aristidou
100+
P: 491
Where should i place the bindingsource.filter?

Will it allow me to display mysql dates on the datagridview w/o the error?
Well that depends on you....do you want the datagrid to always only display the corresponding records?
if so.. put it under form_load
else create a command button ..and put it under
commandbotton1_click
I think it will sove your problem...no promises though...if it does not solve the problem...im still around...
Feb 1 '08 #4

P: 13
Still wont work. Has the same error. I think the error is generated because .net cant display on a datagridview tables that has a diiferent format date field. Is there a way so that .net will interpret mysql date tables as strings?

Expand|Select|Wrap|Line Numbers
  1.         Public Sub refreshinvoices()
  2.         Dim source As New BindingSource
  3.         richdb.connectRichDB() 'opens mysql connection
  4.         source.DataSource = richdb.getTableData("Select * from invoice") 'binds invoice table to bindingsource
  5.         source.Filter = "IsCleared = '0'" 'selects uncleared invoices
  6.         dgvInvoices.DataSource = source
  7.         richdb.disconnectRichDB() 'closes connection
  8. End Sub
Feb 3 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.