471,354 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Problems retreiving a date from MySql

Hi,

I am trying to retreive a record from a MySql table and I get this error
telling :

Unable to convert MySQL date/time value to System.DateTime

I am user the following command:
MySqlDataAdapter.Fill(MydataSet, strTable)

And one of the fields is declared as DateTime.

Can anyone help?

Regards PKin.
--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
5 3405
PKin via DotNetMonster.com wrote:
Hi,

I am trying to retreive a record from a MySql table and I get this error
telling :

Unable to convert MySQL date/time value to System.DateTime

I am user the following command:
MySqlDataAdapter.Fill(MydataSet, strTable)

And one of the fields is declared as DateTime.

Can anyone help?

Regards PKin.


There is a MySQLDataType.MySqlDateTime that you should use instead of
System.DateTime. You can do a MySqlDateTime.DateTime (or might be
GetDateTime can't remember) to get a DateTime object from a mysql
database.

Hope it helps
Chris
Nov 19 '05 #2
Hi Chris,
How can I combine :
MySqlDataAdapter.Fill with MySqlDateTime.GetDateTime.

You see I get the error when I try to fill the dataset. Here is the code

Dim adapter As New MySqlDataAdapter
Dim MydataSet As DataSet = New DataSet
Dim myConnection As New MySqlConnection(myConnString)
<Create the connection string and the query string>

Dim myCommand As New MySqlCommand(StrQuery, myConnection)
myConnection.Open()

adapter.SelectCommand = New MySqlCommand(StrQuery, myConnection)
adapter.Fill(MydataSet, strTable)
<strTable is the name of the table used in the query sting>

Regards
PKin
--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #3
PKin via DotNetMonster.com wrote:
Hi Chris,
How can I combine :
MySqlDataAdapter.Fill with MySqlDateTime.GetDateTime.

You see I get the error when I try to fill the dataset. Here is the code

Dim adapter As New MySqlDataAdapter
Dim MydataSet As DataSet = New DataSet
Dim myConnection As New MySqlConnection(myConnString)
<Create the connection string and the query string>

Dim myCommand As New MySqlCommand(StrQuery, myConnection)
myConnection.Open()

adapter.SelectCommand = New MySqlCommand(StrQuery, myConnection)
adapter.Fill(MydataSet, strTable)
<strTable is the name of the table used in the query sting>

Regards
PKin


I've never done that... I've always used a datareader and loaded up the
datatable myself. Then it really doesn't become an issue.

Sorry
Chris
Nov 19 '05 #4
http://www.google.com/search?sourcei...%2EDateTime%22

I found where the connection string was altered. it is in one of the
first three links, but you may have to follow the thread.

Nov 19 '05 #5
Thanks guys.

That works very nice with the datareader

PKin
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200510/1
Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by carverk | last post: by
1 post views Thread by Guy Erez | last post: by
reply views Thread by Nico den Boer | last post: by
5 posts views Thread by Jonathan Crawford | last post: by
2 posts views Thread by David | last post: by
9 posts views Thread by TC | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.