Solved

Update database from datagridview

Posted on 2014-02-06
4
252 Views
Last Modified: 2014-02-09
On a form I have a datagridview bound to a table in a SQL Server database. When I make edits to the data in the DGV the changes are not being written back to the database. How do I do it?
0
Comment
Question by:TimHudspith
  • 2
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
ktaczala earned 500 total points
ID: 39840940
dataadpater.update()

where dataadapter is whatever you named yours
0
 

Author Comment

by:TimHudspith
ID: 39840942
which event of the datagridview?
0
 
LVL 12

Expert Comment

by:ktaczala
ID: 39840975
Create a save button
0
 

Author Comment

by:TimHudspith
ID: 39843852
This works, but only if I create a SqlCommandBuilder first.

Using cmdbl As SqlCommandBuilder = New SqlCommandBuilder(dap)
         dap.Update(tblGridSource)
End Using

Open in new window

0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question