M
Mike P
I'm using 1 connection to open 3 separate data readers to read data into
3 data grids. However, when I try to use the 2nd reader it says that
the first reader must be closed. So I use Close() to close it and now
it says that 'Object reference not set to an instance of an object' on
that line of code. Can anybody help me out with this?
SqlConnection objConnection = new
SqlConnection(ConfigurationSettings.AppSettings["strConnectTransitTest"]
);
//Associated Call Types
string strAssocCallTypes;
strAssocCallTypes = "SELECT CallType AS 'Call Type', Remark AS
'Description' FROM CallTypeSwitch ";
strAssocCallTypes += "WHERE OSValue = " + intIncomingRoute;
//You must open the connection before populating the DataReader
objConnection.Open();
SqlCommand objCommand = new SqlCommand(strAssocCallTypes,
objConnection);
//Create/Populate the DataReader
SqlDataReader objDataReader = null;
dgAssocCallTypes.DataSource = objCommand.ExecuteReader();
dgAssocCallTypes.DataBind();
//can only have 1 data reader open at any one time in 1 connection
objDataReader.Close();
Cheers,
Mike
3 data grids. However, when I try to use the 2nd reader it says that
the first reader must be closed. So I use Close() to close it and now
it says that 'Object reference not set to an instance of an object' on
that line of code. Can anybody help me out with this?
SqlConnection objConnection = new
SqlConnection(ConfigurationSettings.AppSettings["strConnectTransitTest"]
);
//Associated Call Types
string strAssocCallTypes;
strAssocCallTypes = "SELECT CallType AS 'Call Type', Remark AS
'Description' FROM CallTypeSwitch ";
strAssocCallTypes += "WHERE OSValue = " + intIncomingRoute;
//You must open the connection before populating the DataReader
objConnection.Open();
SqlCommand objCommand = new SqlCommand(strAssocCallTypes,
objConnection);
//Create/Populate the DataReader
SqlDataReader objDataReader = null;
dgAssocCallTypes.DataSource = objCommand.ExecuteReader();
dgAssocCallTypes.DataBind();
//can only have 1 data reader open at any one time in 1 connection
objDataReader.Close();
Cheers,
Mike