For your future reference, the following would probably be a better idea:
public partial class ADOTEST : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindEmpData();
}
}
void BindEmpData()
{
using (SqlConnection cn = new SqlConnection("Data Source=(local); Database=TestDb ; Uid=sa ; password=123 "))
{
using (SqlDataAdapter da = new SqlDataAdapter("Select *From EMPLOYEE", cn))
{
DataSet ds = new DataSet();
da.Fill(ds, "EMPLOYEE");
}
}
Repeater1.DataSource = ds.Tables["EMPLOYEE"];
Repeater1.DataBind();
}
}
The using
blocks will ensure that the resources are cleaned up, even if an exception occurs.
solved what is the mistake this code not showing output? i want to display data using repeater [closed]