Problems retreiving a date from MySql

  • Thread starter Thread starter PKin via DotNetMonster.com
  • Start date Start date
P

PKin via DotNetMonster.com

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.
 
PKin said:
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
 
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
 
PKin said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top