I'm not familiar with using the DataReader and I am a noice in C#. I am getting the following exeception error when trying to make a database connection vai asp.net . I'm trying to test a PDF Generator product from a company called cete software. I'm sure I'm missing something big a obvious but I'm not sure what. I have used System.Data.DataTable successfully many times, this is my first attempt with DataReader. Just looking for ideas on where to look.
Here is the error in the event log:
Exception type: InvalidOperationException
Exception message: ExecuteReader: Connection property has not been initialized.
Here is the sections of my code page that deal with the connection. I am obvious closing the System.Web.UI.Page and Pageload sections later on in the code.
public partial class WebApp_Steve_TableReport : System.Web.UI.Page
static string dBConnString =
protected void Page_Load(object sender, System.EventArgs e)
// Establises connection to the database
SqlConnection connection = GetOpenDBConn();
SqlDataReader data = GetContactListData( connection );
private SqlConnection GetOpenDBConn()
// Creates and opens a database connection
SqlConnection connection = new SqlConnection( dBConnString );
private SqlDataReader GetContactListData( SqlConnection connection )
string from = "09/01/2007";
string to = "09/24/2007";
string siteId = "3";
string transType = "1";
SqlCommand storedProcCommand = new SqlCommand "sp_REPORT_CheckDailySumBySettleDate_DFSOPS");
storedProcCommand.CommandType = CommandType.StoredProcedure;
SqlDataReader dataReader = storedProcCommand.ExecuteReader();