using System; using System.Data; using System.Text; using MySql.Data.MySqlClient; namespace ConsoleApplication2 { class Class1 { public void GetContacts( DateTime startRange, DateTime endRange ) { string conString = "Server=localhost;Database=TestDB;User ID=Dev;pooling=false"; MySqlConnection con = null; try { con = new MySqlConnection( conString ); con.Open(); StringBuilder sql = new StringBuilder(); sql.Append( "SELECT ID, ANTENNAID, TEL_TIMESTAMP, LOS_TIMESTAMP " ); sql.Append( "FROM CONTACT_ACTIVITY " ); // this part of the query causes a failure/exception sql.AppendFormat( "WHERE TEL_TIMESTAMP >= '{0}' ", startRange.ToString( "u" ) ); // eliminate the prior and use this and things are okay //sql.AppendFormat( "WHERE ANTENNAID >= {0} ", 24 ); Console.WriteLine( sql.ToString() ); // for sanity MySqlDataAdapter da = new MySqlDataAdapter( sql.ToString(), con ); DataSet data = new DataSet(); da.Fill( data ); foreach (DataRow row in data.Tables[0].Rows) { Console.WriteLine( "AntennaID:: {0}", row["ANTENNAID"].ToString() ); } da.Dispose(); } catch( MySqlException ex ) { Console.WriteLine( "GetContacts:: {0}", ex.Message ); } catch( Exception ex ) { Console.WriteLine( "GetContacts:: {0}", ex.Message ); } finally { if (con.State == ConnectionState.Open) { con.Close(); } } return; } public void test() { DateTime start = DateTime.Parse( "7/24/2005" ); DateTime end = DateTime.Parse( "7/25/2005" ); GetContacts( start, end ); return; } [STAThread] static void Main(string[] args) { Class1 c = new Class1(); c.test(); return; } } }