unhandled exception
-
hi all, I am getting following error.. An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll. There is no problem with my store procedure as I checked from Query Analyzer. public static void EditTreatInstrument(int Id,string Name,string BarCode,string PDACode,DateTime ExpireTime, int Method ) { SqlCommand cmd = WesServer.GetSqlCommand.Get( Conn , CommandType.StoredProcedure , "pr_EditTreatInstrument" ); cmd.Parameters.Add( GetSqlParameter.Get( "@intId", SqlDbType.Int, Id ) ); cmd.Parameters.Add( GetSqlParameter.Get( "@nvchrName", SqlDbType.NVarChar, Name ) ); cmd.Parameters.Add( GetSqlParameter.Get( "@vchrBarCode", SqlDbType.VarChar, BarCode ) ); cmd.Parameters.Add( GetSqlParameter.Get( "@vchrPDACode", SqlDbType.VarChar, PDACode ) ); cmd.Parameters.Add( GetSqlParameter.Get(" @dtExpireDate", SqlDbType.DateTime, ExpireTime )); cmd.Parameters.Add( GetSqlParameter.Get( "@intMethod", SqlDbType.Int, Method ) ); cmd.ExecuteNonQuery(); } What are the condition when such error can occer ??? Thanks, Sudeep ====== You need a head to program. Cool, fast and sharp.
-
hi all, I am getting following error.. An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll. There is no problem with my store procedure as I checked from Query Analyzer. public static void EditTreatInstrument(int Id,string Name,string BarCode,string PDACode,DateTime ExpireTime, int Method ) { SqlCommand cmd = WesServer.GetSqlCommand.Get( Conn , CommandType.StoredProcedure , "pr_EditTreatInstrument" ); cmd.Parameters.Add( GetSqlParameter.Get( "@intId", SqlDbType.Int, Id ) ); cmd.Parameters.Add( GetSqlParameter.Get( "@nvchrName", SqlDbType.NVarChar, Name ) ); cmd.Parameters.Add( GetSqlParameter.Get( "@vchrBarCode", SqlDbType.VarChar, BarCode ) ); cmd.Parameters.Add( GetSqlParameter.Get( "@vchrPDACode", SqlDbType.VarChar, PDACode ) ); cmd.Parameters.Add( GetSqlParameter.Get(" @dtExpireDate", SqlDbType.DateTime, ExpireTime )); cmd.Parameters.Add( GetSqlParameter.Get( "@intMethod", SqlDbType.Int, Method ) ); cmd.ExecuteNonQuery(); } What are the condition when such error can occer ??? Thanks, Sudeep ====== You need a head to program. Cool, fast and sharp.
The
SqlException
object will contain more information. TheMessage
property and, if multiple error occurred, theErrors
property will give lots of good information. If you cannot see from the exception message then post back to the forum and I'm sure someone will know. Good luck!
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
The
SqlException
object will contain more information. TheMessage
property and, if multiple error occurred, theErrors
property will give lots of good information. If you cannot see from the exception message then post back to the forum and I'm sure someone will know. Good luck!
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
After doing try catch within the error block I caught such exception: System.Data.SqlClient.SqlException: @dtExpireDate is not a parameter for procedure pr_EditTreatInstrument. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at.... so on and when I excluded @dtExpireDate, then I see exception like System.Data.SqlClient.SqlException: Procedure 'pr_EditTreatInstrument' excepts parameter '@dtExpireDate', which was not supplied. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at... so on Thank you, Sudee ====== You need a head to program. Cool, fast and sharp.