Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0.NET4
i am having datagrid view in my form and now i want to insert, delete update data through datagrid view .I have created simple application for insert
code is as follows
private void Form1_Load(object sender, EventArgs e)
           com.Connection = con;

 private void button4_Click(object sender, EventArgs e)
SqlConnection con=new SqlConnection("Data Source=C:\asd;Initial Catalog=shivani;  providerName=System.Data.SqlClient ");
        SqlCommand com = new SqlCommand();

if (txtname.Text != "" & txtage.Text != "")
               com.CommandText = "insert into customer(customerName,customerCode) values ('" + txtname.Text + "','" + txtage.Text + "')";
               MessageBox.Show("record inserted");
           else MessageBox.Show("data entry error");

Now i want to do same thing through datagrid view...
so tell me how to do that
thanks in advance
Posted 1-Jan-13 1:19am
Edited 1-Jan-13 3:19am

1 solution

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

Solution 1

Bind the datagrid with the data adaptor and use it to push data to db.
There are multiple ways to achieve it. Few links to help you out:[^][^]
Hope it helps..

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 529
1 OriginalGriff 307
2 Damith Weerasinghe 295
3 ravikhoda 260
4 Tadit Dash 180
0 Sergey Alexandrovich Kryukov 10,974
1 OriginalGriff 6,667
2 Peter Leow 4,760
3 Abhinav S 3,813
4 Maciej Los 3,565

Advertise | Privacy | Mobile
Web04 | 2.8.140421.2 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid