Home > Uncategorized > Executereader

Executereader


using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

public partial class datareader_Default : System.Web.UI.Page

{

protected SqlConnection mcnSample;

//private int mintTotalRecords = 0;

private int mintPageSize = 0;

//private int mintPageCount = 0;

private int mintCurrentPage = 1;

SqlConnection conn = new SqlConnection(“Data Source=SERVER\\SQLEXPRESS;Initial Catalog=test;Integrated Security=True”);

protected void Page_Load(object sender, EventArgs e)

{

bind();

}

#region bind

protected void bind()

{

string strSql = “”;

int intSkip = 0, i = 0;

SqlDataReader dr;

DataSet ds;

DataTable dt;

intSkip = (this.mintCurrentPage * this.mintPageSize);

strSql = “select sno,issuetitle from issuetitles”;

conn.Open();

SqlCommand cmd = new SqlCommand(strSql, conn);

//cmd.ExecuteNonQuery();

ds = new DataSet();

dr = cmd.ExecuteReader();

dt = ds.Tables.Add(“issuetitles”);

// Add the table columns.

for (i = 0; i = intSkip)

{

DataRow r = dt.NewRow();

// Assign DataReader values to DataRow.

for (i = 0; i = (this.mintPageSize – 1))

// break;

intIdx++;

}

dr.Close();

conn.Close();

// Populate Data Grid

this.GridView1.DataSource = ds.Tables[“issuetitles”].DefaultView;

//GridView1.DataSource = dt;

GridView1.DataBind();

}

#endregion

}

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: