Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9274357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:20:06+00:00 2026-06-18T16:20:06+00:00

I’m using MySQL 4.1.14NT. I’m using ADO.NET and the MySQL connector to query a

  • 0

I’m using MySQL 4.1.14NT.

I’m using ADO.NET and the MySQL connector to query a table that has datetime fields

When I run the query, I get the error “Unable to convert MySQL date/time value to System.DateTime”

The only workaround I have found is to add “Allow Zero Datetime=true” to the connection string for the database.

That stops the error, but now in the dataset, certain date fields return with the date 01/01/0001 00:00:00, but when I run the query in the query browser, they have normal date values.

What can I do?

Edit:

CREATE TABLE `notam_status` (
  `DEMAND_ID` decimal(6,0) NOT NULL default '0',
  `NOTAM_KEY` varchar(25) NOT NULL default '',
  `AIRPORT` varchar(5) default NULL,
  `ARR_DEP` char(1) default NULL,
  `DEP_DATETIME` datetime default NULL,
  `ARR_DATETIME` datetime default NULL,
  `NOTAM_TEXT` text,
  `LAST_MOD_DATETIME` datetime default NULL,
  `STATUS` char(1) default NULL,
  `STATUS_BY` varchar(15) default NULL,
  `STATUS_DATETIME` datetime default NULL,
  `SOURCE_ID` char(1) default NULL,
  `ACCOUNT_ID` varchar(10) default NULL,
  `NOTAM_ID` varchar(9) default NULL,
  `NOTAM_PART` decimal(3,0) default NULL,
  `CNS_LOCATION_ID` varchar(10) default NULL,
  `REMARKS` text,
  `TRIPNUMBER` decimal(6,0) default NULL,
  PRIMARY KEY  (`DEMAND_ID`,`NOTAM_KEY`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='InnoDB free: 11264 kB; InnoDB free: 7168 kB';

Here’s the code I’m using:

    private List<Notam> GetNotamsFor(string airport)
            {
                List<Notam> result = new List<Notam>();

                string sql =
                    @"SELECT a.source_id, a.account_id, a.notam_id, a.notam_part, a.cns_location_id, cast(a.last_mod_datetime as datetime), a.notam_report, a.q_code, a.effective_datetime, a.expire_datetime
                      FROM notams a
                      WHERE (a.cns_location_id = ?airport
                         OR a.cns_location_id =  ?kairport)
                         AND a.source_id != 'F'
                         AND (a.cancel_datetime IS NULL OR a.cancel_datetime > UTC_Timestamp())
                         AND (a.delete_datetime IS NULL OR a.delete_datetime > UTC_Timestamp())
                        ";

                MySqlParameter[] parameters = new MySqlParameter[]
                {
                    new MySqlParameter
                    {
                         ParameterName="airport",
                         MySqlDbType=MySqlDbType.String,
                         Value=airport
                    },
                    new MySqlParameter
                    {
                         ParameterName="kairport",
                         MySqlDbType=MySqlDbType.String,
                         Value="k"+airport
                    }
                };

                DataSet ds = RunMySqlQuery(sql, "weather", parameters);

                // If I look at the dataset, the field "last_mod_datetime' 
                //  has the value 01/01/0001 00:00:00

                if (ds.Tables.Count > 0)
                    foreach (DataRow r in ds.Tables[0].Rows)
                    {
                        result.Add(NotamFiller.FillFrom(r));
                    }

                return result;
            }

 private DataSet RunMySqlQuery(string sql, string database, MySqlParameter[] parameters)
        {

            DataSet ds = new DataSet();
            try
            {
                MySqlCommand mc = new MySqlCommand(sql, _MySqlConnection);
                if (parameters != null)
                    mc.Parameters.AddRange(parameters);
                var adapter = new MySqlDataAdapter(mc);
                adapter.Fill(ds);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return ds;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:20:07+00:00Added an answer on June 18, 2026 at 4:20 pm

    Turns out that other code that populates the table used a MySqlParameter with MySqlDBType.String instead of MySqlDBType.Timestamp when updating the date fields, and it wound up storing 01-01-0001 00:00 in the date fields.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've got a string that has curly quotes in it. I'd like to replace
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am using JSon response to parse title,date content and thumbnail images and place
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have a small JavaScript validation script that validates inputs based on Regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.