Click here to Skip to main content
11,496,146 members (1,740 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
See more: C# WinForm
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
Edited 31-Jan-13 11:43am
Adam R Harris at 31-Jan-13 16:45pm
Shouldn't you be telling us what the error is?
jibesh at 31-Jan-13 16:50pm
what is this ' SqlConnection con = new SqlConnection(@" kkkk");' is that a valid sqlconnection ?
Member 9702410 at 31-Jan-13 16:58pm
the connection is righ i put this "kkk"
Member 9702410 at 31-Jan-13 16:50pm
thanks for your advice!! i only want to know the error?
Adam R Harris at 31-Jan-13 16:53pm
what is the error message you are getting?
Member 9702410 at 31-Jan-13 16:59pm
no message error ,when clickin on button the gridview doesn't be filled
Adam R Harris at 31-Jan-13 17:01pm
Comment out this line:
dataGridView1.DataMember = "client";

and try to run your app.
Member 9702410 at 31-Jan-13 17:08pm
i already comment it but also there is no filling
DinoRondelly at 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 at 31-Jan-13 17:16pm
Dino is right, the code he has posted is what you should be using.
Member 9702410 at 31-Jan-13 16:51pm
yes the connection is righ i put kkk
jibesh at 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??

1 solution

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 at 31-Jan-13 16:57pm
pft, no try catch?!?!?!
what kind of rinky dink operation are you running over there Dino?
DinoRondelly at 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
0 Dnyaneshwar@Pune 692
1 CHill60 248
2 RyanDev 230
3 Sascha Lefèvre 205
4 OriginalGriff 155
0 Sergey Alexandrovich Kryukov 10,372
1 OriginalGriff 8,871
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600

Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2015
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