473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 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 3493
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: carverk | last post by:
Hello All I'm in the middle of moving a MS Access DB to a MySql backend. I have figured out about 90% of the problems I have faced, execpt for this one. I have 3 Queries, which pull records...
1
by: Guy Erez | last post by:
Hi, I'm running queries with MySql 4.0.17 that return thousands of records. Because I need to present them in GUI, I returieve the results in chunks using LIMIT, for example - get first 100,...
0
by: Nico den Boer | last post by:
Hi all, I'm working with: MySql: Database server: mysql-4.1.7-essential-win ODBC driver: MyODBC-3.51.10-x86-win-32bit Administrator: mysql-administrator-1.0.14-win Query browser:...
5
by: Jonathan Crawford | last post by:
Hi I am niew to pho and am having trouble with dates. I can format a date ok so $today=date('d M Y' ) gives me 2 Nov 2005 $dateval is a mysql date
2
by: starfi3ld | last post by:
I got a few errors with this script Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/starfi3ld/domains/starfi3ld.com/public_html/newreleases.php on line...
2
by: David | last post by:
Hi, I am trying to create a simple ASP web counter for my site, but seem to have an error somewhere ??? I am connecting to a MySQL server (works fine) hit-marker = Varchar hit_date = Date...
4
by: pushpinderbagga | last post by:
hi I need help in storing and retreiving hindi text from myql... I have done the folowwing ... mysql_query("SET NAMES 'utf8'"); <META http-equiv=Content-Type content="text/html;...
4
by: atyndall | last post by:
OK, this is the relevant portion script: <?php $username = '__'; // MySQL Database Username. $password = '__'; // MySQL Database Password. $server = '__'; // MySQL Database server (most...
9
by: TC | last post by:
Hi. I have some ASP written in VB.net which is currently installed on a customers server. The asp connects to a local MySql database and retrieves data for the customers customers. If you see...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.