Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1) Exception Information
- *********************************************
- Exception Type: System.NullReferenceException
- Message: Object reference not set to an instance of an object.
- Data: System.Collections.ListDictionaryInternal
- TargetSite: Void Bind(System.Data.SqlClient.TdsParserStateObject)
- HelpLink: NULL
- Source: System.Data
- StackTrace Information
- *********************************************
- at System.Data.SqlClient.SqlDataReader.Bind(TdsParserStateObject stateObj)
- at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
- at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
- at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult esult)
- at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
- at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
- at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
- at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
- 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 MyCode.Shared.Data.DataSocket.GetTable(String SPString)
- at <rest of stack trace>
- public DataTable GetTable(string SPString)
- {
- //Setup the data objects by calling helper
- prepareDataAdaptor(SPString,CommandType.Text);
- dataAdaptor.Fill(dataSet);
- dataAdaptor.SelectCommand.Connection.Close();
- DataTable dt;
- //ensure we dispose okay
- using(dataSet)
- {
- if(dataSet.Tables.Count==0)
- {
- dataSet.Tables.Add(new DataTable("EmptyTable"));
- }
- dt=dataSet.Tables[0];
- //because we are disposing we need to remove the table from the dataset
- dataSet.Tables.Clear();
- }
- return dt;
- }
- private void prepareDataAdaptor(string SPString,CommandType Type)
- {
- checkForConnection();
- dataSet=new DataSet();
- dbCommand.CommandText=SPString;
- dbCommand.CommandTimeout = MySettings.CommandTimeout;
- dataAdaptor.SelectCommand=dbCommand;
- dataAdaptor.SelectCommand.CommandType=Type;
- dataAdaptor.SelectCommand.Connection=dbConnection;
- dataAdaptor.SelectCommand.Parameters.Clear();
- }
- dataAdaptor.SelectCommand.Connection.Close();
Add Comment
Please, Sign In to add comment