string s = "select * from StudentDetails";     
SqlDataAdapter da = new SqlDataAdapter(s, con);
DataSet ds = new DataSet();
DataRow therow;
try
{
    con.Open();
    da.Fill(ds, "StudentDetails");
    TextBox1.Text = ""

    string s = "select * from StudentDetails";
    SqlDataAdapter da = new SqlDataAdapter(s, con);
    DataSet ds = new DataSet();
    DataRow therow;
    try
    {
        con.Open();
        da.Fill(ds, "StudentDetails");
        TextBox1.Text = "";
        con.Close();
        int i = ds.Tables["StudentDetails"].Rows.Count;

        for (int j = 0; j < i; j++)
        {
            therow = ds.Tables["StudentDetails"].Rows[j];

            TextBox1.Text += therow["ContactEmail"].ToString() + ",";
            TextBox1.Text += therow["FatherEmail1"].ToString() + ",";
            TextBox1.Text += therow["FatherEmail2"].ToString() + ",";
            TextBox1.Text += therow["MotherEmail1"].ToString() + ",";
            TextBox1.Text += therow["MotherEmail2"].ToString() + ",";
        }

        TextBox1.Text = TextBox1.Text.TrimEnd(',');
    }
    catch (SqlException ex)
    {
        con.Close();
    }

    con.Close();
    int i = ds.Tables["StudentDetails"].Rows.Count;
    for (int j = 0; j < i; j++)
    {
        therow = ds.Tables["StudentDetails"].Rows[j];
        TextBox1.Text += therow["ContactEmail"].ToString() + ",";
        TextBox1.Text += therow["FatherEmail1"].ToString() + ",";
        TextBox1.Text += therow["FatherEmail2"].ToString() + ",";
        TextBox1.Text += therow["MotherEmail1"].ToString() + ",";
        TextBox1.Text += therow["MotherEmail2"].ToString() + ",";
    }
    TextBox1.Text = TextBox1.Text.TrimEnd(',');     
}
catch (SqlException ex)
{
    con.Close();
}

Edited 3 Years Ago by deceptikon: Fixed code formatting

Hello there sir, the number you are dialing is not in service anymore, please hold, someone will be there shortly. In the meanwhile please post the error you are getting with the error message.
Thanks

This article has been dead for over six months. Start a new discussion instead.