SQLConnection object in ADO.NET (Part - 2)
Step 1.Take an Grid View In Webform
--------------------------------------------------C# Code -------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
namespace WebApplication2
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"data source=saibaba-pc\server; database=Genreal; integrated security=SSPI");
try
{
SqlCommand cmd = new SqlCommand("Select * from Mobiles",con);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
GridView1.DataSource = rdr;
GridView1.DataBind();
}
catch
{
}
finally
{
con.Close();
}
}
}
}
---------------------------------------------END OF C# CODE-----------------------------------------
0 comments:
Post a Comment