Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to Save DataGridView Changes into Database

$
0
0
Bellow is the code :
DataSet ds = new DataSet();            
DataTable uniquedt = dt.DefaultView.ToTable(true, "StudentNo");
  
foreach (DataRow uniuqedr in uniuqedt.Rows)
        {                
                string str = "select StudentNo,StudentName from Students where StudentNo = '"+uniuqedr["StudentNo"]+"' ";
                SqlDataAdapter da = new SqlDataAdapter(str, Class1.conn);
                da.Fill(ds,"StudentDetail");
        }
          
        DGStudentGrid.DataSource = ds.Tables[0];
I have uniquedt which has unique StudentNo from Datatable dt.
Now I am looping through uniquedt to get student names and my Dataset ds now has studentno,studentname.
In the last line I am inserting dataset data into DataGridView.
My question :Now I want to make changes into datagridview data and I want to save those changes into Database.
da.Update(ds); did not work.
Please help.


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>