I have a DataClassLibrary I use for the connectionString and then I also have the C# code behind the ASP page. I want to be able to use While(reader.read()) in my ASP page so that I can get the multiple values the reader returns. How can I go about implementing this? I have provided the code below for my Data Class and the ASP page.
Data Class:
reader = DBHelper.executeQuery(dbConn, sqlString.ToString(), parameters);
if (reader != null)
{
if (reader.Read())
{
OrderID = (int)Convert.ToInt32(reader["OrderID"]);
CaseNum6 = (int)Convert.ToInt32(reader["CaseNum6"]);
CaseNum9 = (int)Convert.ToInt32(reader["CaseNum9"]);
Group = (int)Convert.ToInt32(reader["Group"]);
Completed = (bool)reader["Completed"];
}
else
throw new Exception("No record returned");
reader.Close();
reader.Dispose();
dbConn.Close();
dbConn.Dispose();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (dbConn != null)
{
try { dbConn.Close(); dbConn.Dispose(); }
catch { }
}
if (reader != null)
{
try { reader.Close(); reader.Dispose(); }
catch { }
}
}
ASP page to implement on:
LineAData NewDataA = new LineAData();
LineAData NewDataB = new LineAData();
string connString = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
NewDataA.load(1,3);
NewDataB.load(2,3);
L1.Text = NewDataA.CaseNum6.ToString();
L2.Text = NewDataA.CaseNum9.ToString();
L7.Text = NewDataA.CaseNum6.ToString();
L8.Text = NewDataA.CaseNum9.ToString();
L4.Text = NewDataB.CaseNum6.ToString();
L5.Text = NewDataB.CaseNum9.ToString();
L10.Text = NewDataB.CaseNum6.ToString();
L11.Text = NewDataB.CaseNum9.ToString();
}