Click here to Skip to main content
13,403,829 members (50,666 online)
Rate this:
Please Sign up or sign in to vote.
See more:
what error here?

private void fillgrid()
                DataSet ds = new DataSet();
                SqlConnection con = new SqlConnection(@" kkkk");
                SqlCommand comm = new SqlCommand("select * from client", con);
                SqlDataAdapter adapt = new SqlDataAdapter();
                adapt.SelectCommand = comm;
                dataGridView1.DataSource = ds;
                dataGridView1.DataMember = "client";
            catch (Exception ex)
Posted 31-Jan-13 11:39am
Updated 31-Jan-13 11:43am
Adam R Harris 31-Jan-13 16:45pm
Shouldn't you be telling us what the error is?
jibesh 31-Jan-13 16:50pm
what is this ' SqlConnection con = new SqlConnection(@" kkkk");' is that a valid sqlconnection ?
Member 9702410 31-Jan-13 16:50pm
thanks for your advice!! i only want to know the error?
Member 9702410 31-Jan-13 16:51pm
yes the connection is righ i put kkk
Adam R Harris 31-Jan-13 16:53pm
what is the error message you are getting?
jibesh 31-Jan-13 16:54pm
so what's your problem here? by looking at the code If i say I dont see any error. will it be ok??
Member 9702410 31-Jan-13 16:58pm
the connection is righ i put this "kkk"
Member 9702410 31-Jan-13 16:59pm
no message error ,when clickin on button the gridview doesn't be filled
Adam R Harris 31-Jan-13 17:01pm
Comment out this line:
dataGridView1.DataMember = "client";

and try to run your app.
Member 9702410 31-Jan-13 17:08pm
i already comment it but also there is no filling
DinoRondelly 31-Jan-13 17:13pm
Try what i added as a solution, just copy and paste it and change the connection string, should work.
Adam R Harris 31-Jan-13 17:16pm
Dino is right, the code he has posted is what you should be using.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

try this,

 using (SqlConnection con = new SqlConnection(YOUR CONNECTION STRING))

  // Create new DataAdapter
   using (SqlDataAdapter adapt = new SqlDataAdapter("select * from client", con))
      // Use DataAdapter to fill DataTable
      DataTable ds = new DataTable();

      // fill your grid
      dataGridView1.DataSource = ds;
catch(Exception ex)
Adam R Harris 31-Jan-13 16:57pm
pft, no try catch?!?!?!
what kind of rinky dink operation are you running over there Dino?
DinoRondelly 31-Jan-13 16:59pm
Touche .. updated solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.1802120.2 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100