Click here to Skip to main content
15,897,360 members

Comments by jdanastasi (Top 9 by date)

jdanastasi 27-Mar-13 15:13pm View    
y static increments the button works fine for the first 2 records but fails to output the third
jdanastasi 27-Mar-13 14:57pm View    
protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection();
con.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True";
con.Open();

ds = new DataSet();
string sql = "SELECT * FROM Internet";
da = new SqlDataAdapter(sql, con);
da.Fill(ds, "Internet");
Maxrows = ds.Tables["Internet"].Rows.Count;
Records();
con.Close();
Label2.Text = inc.ToString();
Label3.Text = Maxrows.ToString();



}


private void Records()
{
drow = ds.Tables["Internet"].Rows[inc];
Label1.Text = drow.ItemArray.GetValue(1).ToString();
inc++;

}



protected void next1_Click(object sender, EventArgs e)
{
if (inc < Maxrows)
{

Records();

Label2.Text = inc.ToString();
}


}

}
jdanastasi 27-Mar-13 14:57pm View    
Deleted
protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection();
con.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True";
con.Open();

ds = new DataSet();
string sql = "SELECT * FROM Internet";
da = new SqlDataAdapter(sql, con);
da.Fill(ds, "Internet");
Maxrows = ds.Tables["Internet"].Rows.Count;
Records();
con.Close();
Label2.Text = inc.ToString();
Label3.Text = Maxrows.ToString();



}


private void Records()
{
drow = ds.Tables["Internet"].Rows[inc];
Label1.Text = drow.ItemArray.GetValue(1).ToString();
inc++;

}



protected void next1_Click(object sender, EventArgs e)
{
if (inc < Maxrows)
{

Records();

Label2.Text = inc.ToString();
}


}

}
this is all the code I have
jdanastasi 27-Mar-13 14:30pm View    
inc is 0 and acts as a counter whilst max rows is the number of records I have in the database
jdanastasi 27-Mar-13 14:18pm View    
I am still having the same result and int inc = 0; is outside the function pageload