|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
date type conversion error ignoredThe code below executes fine without throwing an exception. Unfortunately, in my real problem the command executes a stored proc, which completes happily despite this error. The error results in NULL values in rows that overflow the data type and values for the ones that don't and no way of knowing that the operation has partially failed apart from looking at the table and spotting it. I've got the problem with ODBC really, but I tried ADO.Net to find out if it's been resolved by a newer technology ... and it hasn't. Am I missing something here ? (I used the SQLDataReader as I recall in ODBC you get the output from the command as the last recordset or something like that). <c#> using System; namespace type_error_in_sql { class Class1 { [STAThread] static void Main(string[] args) { try { System.Data.SqlClient.SqlConnection lCnx = new System.Data.SqlClient.SqlConnection( "server=localhost;database=master;integrated security=sspi;" ) ; lCnx.Open() ; System.Data.SqlClient.SqlCommand lCmd = lCnx.CreateCommand() ; lCmd.Connection = lCnx ; lCmd.CommandText = "select cast( 1234.1234 as decimal(3,3) )" ; lCmd.CommandType = System.Data.CommandType.Text ; System.Data.SqlClient.SqlDataReader lRdr = lCmd.ExecuteReader() ; if ( lRdr.HasRows ) { int x = 0 ; } lCnx.Close() ; } catch( System.Data.SqlClient.SqlException se ) { int x = 1 ; } catch( System.Exception e ) { int x = 1 ; } } } } </c#> Thanks, Binary Bear It seems that both ANSI_WARNINGS and ARITHABORT are OFF:
http://msdn2.microsoft.com/en-us/library/ms189118.aspx Regards: Jesús López VB MVP |
|||||||||||||||||||||||