ASp.net

Saturday, September 12, 2015

how to show data in datagridview in c#

5 comments:

  1. private void Form1_Load(object sender, EventArgs e)
    {
    Getdata();
    }

    public void Getdata()
    {
    try
    {
    SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=I:\C3 soft\WindowsFormsApplication2\WindowsFormsApplication2\MTechSqlDatabase.mdf;Integrated Security=True;Connect Timeout=30");
    con.Open();
    SqlCommand cmd = new SqlCommand("Select * From Customer", con);
    SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
    dataGridView1.Rows.Clear();
    while ((rdr.Read() == true))
    {
    dataGridView1.Rows.Add(rdr[3], rdr[12]);
    }
    con.Close();
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    }

    ReplyDelete
  2. I have read your article, it is very informative and helpful for me.I admire the valuable information you offer in your articles. Thanks for posting it.. Tableau Data Blending

    ReplyDelete
  3. Thanks for the best blog. it was very useful for me.keep sharing such ideas in the future as well.

    data science training in noida

    ReplyDelete
  4. You re in point of fact a just right webmaster. The website loading speed is amazing. It kind of feels that you're doing any distinctive trick. Moreover, The contents are masterpiece. you have done a fantastic activity on this subject!
    data science certification malaysia

    ReplyDelete
  5. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one.
    full stack web development course malaysia

    ReplyDelete

MM Online Express | Best product Review and Online Marketing site

MM Online Express | Best product Review and Online Marketing site