using System.Data; using System.Data.SqlClient; protected void Page_Load(object sender, EventArgs e) { BindGrid(); } public void BindGrid() {
//SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString); SqlConnection con = new SqlConnection("Data Source=BITPLUS5\\SqlExpress;Initial Catalog=temp;User ID=sa;pwd=bit123;"); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "select * from chat order by 1";
cmd.Connection = con;
con.Open(); SqlDataReader dr = cmd.ExecuteReader();
grvDemo.DataSource = dr;
grvDemo.DataBind(); }
|