|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SqlDataAdapter.Fill exception in Release but not Debug Modegreatly appreciated! I've been having a problem with the SqlDataAdapter's Fill method while attempting to fill a dataset with the results of a query I execute against a SQL Server 2005 database. The exception only occurs in release mode, not in debug mode. Additionally, the exception seems to be occuring when I query a particular table (I am able to query other tables which have fewer fields \ records without difficulty). The query I am using is: SELECT * FROM tablename I've included a sample of the code I am using below. This function is part of a class I created to handle querying my database. Other information which may be of use: I am using VB.NET 2005, connecting to SQL Server 2005 (db is on the same machine as the exe I am creating). I know my connectionstring is valid as I have a series of validation functions which execute when the user logs into my application to verify that they have permission to the database and are part of certain roles within SQL Server prior to allowing them access to the application. I have gotten so frustrated with this exception that I have changed my code to use OleDB instead of the SqlClient and the query throwing the exception works when I use OleDB! Has anyone out there experienced anything similar? If so, were you able to determine what was causing the error? At this point I have code which works but I would love to know why I get the error using SqlClient and only in Release Mode. Sample Function: Private m_ConnString As String Private m_CN As SqlClient.SqlConnection Public Function GetDataSet(ByVal SQL As String) As DataSet Dim ds As DataSet Try m_CN = New SqlClient.SqlConnection(m_ConnString) m_CN.Open() Dim cmd As New SqlClient.SqlCommand(SQL, m_CN) Dim Adapt As New SqlClient.SqlDataAdapter(cmd) ds = New DataSet() Adapt.Fill(ds) 'Error Seems to be occuring here Catch Ex As Exception Throw End Try Return ds End Function StackTrace output when exception occurs: DefaultSource Error: 2 : Object reference not set to an instance of an object. at System.Data.SqlClient.SqlDataReader.ReadColumnData() at System.Data.SqlClient.SqlDataReader.ReadColumn(Int32 i, Boolean setTimeout) at System.Data.SqlClient.SqlDataReader.GetValueInternal(Int32 i) at System.Data.SqlClient.SqlDataReader.GetValues(Object[] values) at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] values) at System.Data.ProviderBase.SchemaMapping.LoadDataRow() at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping) at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue) at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, 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 SqlManager.CAPSDB.GetDataSet(String Sql, Int32 Timeout) in C:\Projects\VisualStudioNET\SQLManager\SQLManager\CAPSDB.vb:line 124 at SqlManager.frmMgr.ExecuteQuery(Boolean ShiftKeyPressed) in C:\Projects\VisualStudioNET\SQLManager\SQLManager\frmMgr.vb:line 176 TLentine,
I don't have the answer but I know that your question is not new, can you have a look yourself what is written about that in this newsgroup. http://groups.google.com/group/microsoft.public.dotnet.framework.adonet/search?group=microsoft.public.dotnet.framework.adonet&q=debug+release+mode&qt_g=1&searchnow=Search+this+group I hope this helps, Cor Show quote "TLentine" <TLent***@discussions.microsoft.com> schreef in bericht news:B12A5371-CF13-4F74-A01F-07BFE4699D59@microsoft.com... >I apologize in advance for the lengthy post, but any help or insight would >be > greatly appreciated! > > I've been having a problem with the SqlDataAdapter's Fill method while > attempting to fill a dataset with the results of a query I execute against > a > SQL Server 2005 database. The exception only occurs in release mode, not > in > debug mode. Additionally, the exception seems to be occuring when I query > a > particular table (I am able to query other tables which have fewer fields > \ > records without difficulty). > > The query I am using is: SELECT * FROM tablename > > I've included a sample of the code I am using below. This function is part > of a class I created to handle querying my database. > > Other information which may be of use: I am using VB.NET 2005, connecting > to > SQL Server 2005 (db is on the same machine as the exe I am creating). I > know > my connectionstring is valid as I have a series of validation functions > which > execute when the user logs into my application to verify that they have > permission to the database and are part of certain roles within SQL Server > prior to allowing them access to the application. > > I have gotten so frustrated with this exception that I have changed my > code > to use OleDB instead of the SqlClient and the query throwing the exception > works when I use OleDB! > > Has anyone out there experienced anything similar? If so, were you able to > determine what was causing the error? At this point I have code which > works > but I would love to know why I get the error using SqlClient and only in > Release Mode. > > Sample Function: > > Private m_ConnString As String > Private m_CN As SqlClient.SqlConnection > > Public Function GetDataSet(ByVal SQL As String) As DataSet > > Dim ds As DataSet > > Try > > m_CN = New SqlClient.SqlConnection(m_ConnString) > m_CN.Open() > > Dim cmd As New SqlClient.SqlCommand(SQL, m_CN) > Dim Adapt As New SqlClient.SqlDataAdapter(cmd) > > ds = New DataSet() > > Adapt.Fill(ds) 'Error Seems to be occuring here > > Catch Ex As Exception > Throw > End Try > > Return ds > > End Function > > StackTrace output when exception occurs: > > DefaultSource Error: 2 : Object reference not set to an instance of an > object. at System.Data.SqlClient.SqlDataReader.ReadColumnData() > at System.Data.SqlClient.SqlDataReader.ReadColumn(Int32 i, Boolean > setTimeout) > at System.Data.SqlClient.SqlDataReader.GetValueInternal(Int32 i) > at System.Data.SqlClient.SqlDataReader.GetValues(Object[] values) > at > System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] > values) > at System.Data.ProviderBase.SchemaMapping.LoadDataRow() > at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping) > at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, > DataTable datatable, String srcTable, DataReaderContainer dataReader, > Int32 > startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object > parentChapterValue) > at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, > IDataReader dataReader, Int32 startRecord, Int32 maxRecords) > at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, > DataTable[] datatables, 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 SqlManager.CAPSDB.GetDataSet(String Sql, Int32 Timeout) in > C:\Projects\VisualStudioNET\SQLManager\SQLManager\CAPSDB.vb:line 124 > at SqlManager.frmMgr.ExecuteQuery(Boolean ShiftKeyPressed) in > C:\Projects\VisualStudioNET\SQLManager\SQLManager\frmMgr.vb:line 176 > > The only time I had a similar problem was using typed datasets and the
connection string was different in the connection object than what I was using for a particular fill. Show quote "TLentine" <TLent***@discussions.microsoft.com> wrote in message news:B12A5371-CF13-4F74-A01F-07BFE4699D59@microsoft.com... >I apologize in advance for the lengthy post, but any help or insight would >be > greatly appreciated! > > I've been having a problem with the SqlDataAdapter's Fill method while > attempting to fill a dataset with the results of a query I execute against > a > SQL Server 2005 database. The exception only occurs in release mode, not > in > debug mode. Additionally, the exception seems to be occuring when I query > a > particular table (I am able to query other tables which have fewer fields > \ > records without difficulty). > > The query I am using is: SELECT * FROM tablename > > I've included a sample of the code I am using below. This function is part > of a class I created to handle querying my database. > > Other information which may be of use: I am using VB.NET 2005, connecting > to > SQL Server 2005 (db is on the same machine as the exe I am creating). I > know > my connectionstring is valid as I have a series of validation functions > which > execute when the user logs into my application to verify that they have > permission to the database and are part of certain roles within SQL Server > prior to allowing them access to the application. > > I have gotten so frustrated with this exception that I have changed my > code > to use OleDB instead of the SqlClient and the query throwing the exception > works when I use OleDB! > > Has anyone out there experienced anything similar? If so, were you able to > determine what was causing the error? At this point I have code which > works > but I would love to know why I get the error using SqlClient and only in > Release Mode. > > Sample Function: > > Private m_ConnString As String > Private m_CN As SqlClient.SqlConnection > > Public Function GetDataSet(ByVal SQL As String) As DataSet > > Dim ds As DataSet > > Try > > m_CN = New SqlClient.SqlConnection(m_ConnString) > m_CN.Open() > > Dim cmd As New SqlClient.SqlCommand(SQL, m_CN) > Dim Adapt As New SqlClient.SqlDataAdapter(cmd) > > ds = New DataSet() > > Adapt.Fill(ds) 'Error Seems to be occuring here > > Catch Ex As Exception > Throw > End Try > > Return ds > > End Function > > StackTrace output when exception occurs: > > DefaultSource Error: 2 : Object reference not set to an instance of an > object. at System.Data.SqlClient.SqlDataReader.ReadColumnData() > at System.Data.SqlClient.SqlDataReader.ReadColumn(Int32 i, Boolean > setTimeout) > at System.Data.SqlClient.SqlDataReader.GetValueInternal(Int32 i) > at System.Data.SqlClient.SqlDataReader.GetValues(Object[] values) > at > System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] > values) > at System.Data.ProviderBase.SchemaMapping.LoadDataRow() > at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping) > at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, > DataTable datatable, String srcTable, DataReaderContainer dataReader, > Int32 > startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object > parentChapterValue) > at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, > IDataReader dataReader, Int32 startRecord, Int32 maxRecords) > at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, > DataTable[] datatables, 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 SqlManager.CAPSDB.GetDataSet(String Sql, Int32 Timeout) in > C:\Projects\VisualStudioNET\SQLManager\SQLManager\CAPSDB.vb:line 124 > at SqlManager.frmMgr.ExecuteQuery(Boolean ShiftKeyPressed) in > C:\Projects\VisualStudioNET\SQLManager\SQLManager\frmMgr.vb:line 176 > > |
|||||||||||||||||||||||