[Mono-devel-list] DateTime Parameters in MSSQL Server

Chris van Wyk chris at jib.co.za
Tue Jul 12 09:42:41 EDT 2005


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 lists.ximian.com [mailto:mono-devel-list-
> bounces at lists.ximian.com] On Behalf Of Hubert FONGARNAND
> Sent: 12 July 2005 03:28 PM
> To: mono-devel-list at lists.ximian.com
> 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
> source=10.69.100.93;initial
> catalog=Fiche_Produit";
> 
> 
> 	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
> conversion
> du type de données varchar en datetime.
> Erreur de conversion du type de données varchar en datetime.
> in [0x00034]
> (at
> /home/hubert/mono/mcs/class/System.Data/System.Data.SqlClient/SqlConnectio
> n.cs:266)
> System.Data.SqlClient.SqlConnection:ErrorHandler (System.Object sender,
> Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs e)
> in (wrapper delegate-invoke)
> System.MulticastDelegate:invoke_void_object_TdsInternalErrorMessageEventAr
> gs
> (object,Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs)
> 
> 
> In english : error when converting a varchar datatype into a datetime
> 
> thanks
> 
> _______________________________________________
> Ce message et les éventuels documents joints peuvent contenir des
> informations confidentielles.
> Au cas où il ne vous serait pas destiné, nous vous remercions de bien
> vouloir le supprimer et en aviser immédiatement l'expéditeur. Toute
> utilisation de ce message non conforme à sa destination, toute diffusion
> ou publication, totale ou partielle et quel qu'en soit le moyen est
> formellement interdite.
> Les communications sur internet n'étant pas sécurisées, l'intégrité de ce
> message n'est pas assurée et la société émettrice ne peut être tenue pour
> responsable de son contenu.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list