Trying to debug an exception

  • Thread starter Thread starter Frank Rizzo
  • Start date Start date
F

Frank Rizzo

Hello. Every now and then (it's rare), i get an exception when calling
SqlDataAdapter.Fill. The code is calling a stored procedure and
attempts to stuff the results into a dataset. It yields the following
exception. I am trying to understand what the exception is actually
complaining about. Is it a problem with the data that came back or is
it an issue inside the stored procedure? Any alternative ways to nail
down this issue would also be appreciated.


7/18/2005 4:29 PM System.Data.SqlClient.SqlException: Invalid column
name 'OL_ID'.
at System.Data.SqlClient.SqlDataReader.Read()
at System.Data.SqlClient.SqlDataReader.NextResult()
at System.Data.Common.DbDataAdapter.FillNextResult(IDataReader
dataReader)
at System.Data.Common.DbDataAdapter.FillFromReader(Object data,
String srcTable, IDataReader dataReader, Int32 startRecord, Int32
maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data,
Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand
command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at CC.Viper.DataLayer.Database.CreateDataSet(SqlCommand command) in
C:\Code.Net\Application\Data Layer\Database.cs:line 287
at CC.Viper.DataLayer.Database.GetOrderLines(Int32 inserterID,
DateTime occasionStartDate, DateTime occasionStopDate, Int32&
resultCode, String& resultText, Int32 debugLevel) in
C:\Code.Net\Application\Data Layer\Database.cs:line 764
 
Frank Rizzo said:
Hello. Every now and then (it's rare), i get an exception when calling
SqlDataAdapter.Fill. The code is calling a stored procedure and
attempts to stuff the results into a dataset. It yields the following
exception. I am trying to understand what the exception is actually
complaining about. Is it a problem with the data that came back or is
it an issue inside the stored procedure? Any alternative ways to nail
down this issue would also be appreciated.

I'd try running SQL Profiler while your program is running - that
should show whether or not an error occurred in the stored proc itself.
 
Frank said:
Hello. Every now and then (it's rare), i get an exception when calling
SqlDataAdapter.Fill. The code is calling a stored procedure and
attempts to stuff the results into a dataset. It yields the following
exception. I am trying to understand what the exception is actually
complaining about. Is it a problem with the data that came back or is
it an issue inside the stored procedure? Any alternative ways to nail
down this issue would also be appreciated.


7/18/2005 4:29 PM System.Data.SqlClient.SqlException: Invalid
column name 'OL_ID'.
at System.Data.SqlClient.SqlDataReader.Read()
at System.Data.SqlClient.SqlDataReader.NextResult()
at System.Data.Common.DbDataAdapter.FillNextResult(IDataReader
dataReader)
at System.Data.Common.DbDataAdapter.FillFromReader(Object data,
String srcTable, IDataReader dataReader, Int32 startRecord, Int32
maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data,
Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand
command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at CC.Viper.DataLayer.Database.CreateDataSet(SqlCommand command) in
C:\Code.Net\Application\Data Layer\Database.cs:line 287
at CC.Viper.DataLayer.Database.GetOrderLines(Int32 inserterID,
DateTime occasionStartDate, DateTime occasionStopDate, Int32&
resultCode, String& resultText, Int32 debugLevel) in
C:\Code.Net\Application\Data Layer\Database.cs:line 764

Based on the exception I would guess you are selecting 'OL_ID' from your
table which does not exist.

Try running the stored proc/statement through query analyzer or some
such in the same way as your method would be running it.

HTH
JB
 
Frank said:
Hello. Every now and then (it's rare), i get an exception when
calling SqlDataAdapter.Fill. The code is calling a stored procedure
and attempts to stuff the results into a dataset. It yields the
following exception. I am trying to understand what the exception is
actually complaining about. Is it a problem with the data that came
back or is it an issue inside the stored procedure? Any alternative
ways to nail down this issue would also be appreciated.

catch the SqlException and view the Errors collection: that's where
the SqlServer responses are stored. Maybe that will give you a lead
as to where the problem really is.

Hans Kesting
 
Hans said:
catch the SqlException and view the Errors collection: that's where
the SqlServer responses are stored. Maybe that will give you a lead
as to where the problem really is.

Hans Kesting

Thank you. I didn't realize SqlException had an errors collection.
 
Back
Top