SPAM: RE: [Mono-devel-list] DateTime Parameters in MSSQL Server

Michael J. Ryan tracker1_lists at
Wed Jul 13 16:55:00 EDT 2005

AFAIK, sql server should accept an ISO formatted datetime..
iirc: yyyy-MM-ddTHH:mm:ss.fff
not sure about appending a zzz for the offset?

maybe entering as UTC with a "Z" after the .fff ?

Chris van Wyk wrote:
> Hi,
> Datetime has also been giving me huge amounts of problems. 
> The work around for me was to convert the item using ToString("s"). If you
> are going to use stored procs, you will need to modify your stored proc
> parameters in the sql statement to string in stead of datetime.
> I have also been able to get the Microsoft.ApplicationBlocks.Data going with
> modification to specific DateTime parameter formatting.
> There seems to be problems with the data adapter using the sqlhelper from
> the above. I am getting concurrency errors on updates for instance. If
> someone else has had concurrency errors please let me know as I have been
> able to work round this, but I'm not sure if it is a bug in Mono.
> I am using 1.1.7 and have not tested the above on 1.1.8
> Regards
> Chris
>>-----Original Message-----
>>From: mono-devel-list-bounces at [mailto:mono-devel-list-
>>bounces at] On Behalf Of Hubert FONGARNAND
>>Sent: 12 July 2005 03:28 PM
>>To: mono-devel-list at
>>Subject: [Mono-devel-list] DateTime Parameters in MSSQL Server
>>I've an issue with datetime parameters with MSSQL Server in Mono...
>>It seem's that the parameters is badly sent to the SQL Server...
>>Please test that :
>>using System;
>>using System.Data;
>>using System.Data.SqlClient;
>>class MainClass
>>	static string cnx="user id=sa;password=sa;data
>>	public static void Main(string[] args)
>>	{
>>		Console.WriteLine("Hello World!");
>>		SqlCommand cmd=new SqlCommand();
>>		cmd.Connection=new SqlConnection(cnx);
>>		cmd.CommandText="INSERT INTO essais (date) VALUES (@date)";
>>		cmd.Parameters.Clear();
>>	cmd.Parameters.Add("@date",SqlDbType.DateTime).Value=DateTime.Now;
>>		cmd.Connection.Open();
>>		cmd.ExecuteNonQuery();
>>		cmd.Connection.Close();
>>	}
>>it returns :
>>Unhandled Exception: System.Data.SqlClient.SqlException: Erreur de
>>du type de données varchar en datetime.
>>Erreur de conversion du type de données varchar en datetime.
>>in [0x00034]
>>System.Data.SqlClient.SqlConnection:ErrorHandler (System.Object sender,
>>Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e)
>>in (wrapper delegate-invoke)
>>In english : error when converting a varchar datatype into a datetime

Michael J. Ryan - tracker1(at)theroughnecks(dot)com -
icq: 4935386  -  AIM/AOL: azTracker1  -  Y!: azTracker1  -  MSN/Win: (email)

More information about the Mono-devel-list mailing list