473,404 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How to save datagridview data to a sql table?

347 100+
I have a form that shows users data from a sql query. What I want to be able to do is when users make a change, they press a save button, the edited/changed data is saved to a new table and then the window is closed. I've looked for several tutorials for this. Can anyone give me an example of a good tutorial or a code example?

My database that the user would be saving to is called exceptionsedit.

The code I have this far is this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles saveButton.Click
  2.         Dim sql As String = "Insert * Into ExceptionsEdit"
  3.         Dim oCmd As System.Data.SqlClient.SqlCommand
  4.         Dim oDr As System.Data.SqlClient.SqlDataReader
  5.         oCmd = New System.Data.SqlClient.SqlCommand
  6.         Try
  7.             With oCmd
  8.                 .Connection = New System.Data.SqlClient.SqlConnection("Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx")
  9.                 .Connection.Open()
  10.                 .CommandType = CommandType.Text
  11.                 oDr = .ExecuteReader()
  12.             End With
  13.             oDr.Close()
  14.             oCmd.Connection.Close()
  15.         Catch ex As Exception
  16.             MessageBox.Show(ex.Message)
  17.             oCmd.Connection.Close()
  18.         End Try
  19.         Close()
  20.         saveButton.Enabled = False
  21.     End Sub
  22.  
But from how I understand how datagridviews work, that the user can edit in the form without having to click on save.
Jan 24 '11 #1
0 1577

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: G Uljee | last post by:
Hi, I've an application with an Access database (max 10000 records). I want to save per 1000 records at once into the Access database, witch option do you prefer (example)? Someone...
0
by: Tommy Christian | last post by:
Hi! Anyone who knows about saving serialized data to database, coz I have a problem with that. If I just serialize my session data and then deserialize it, it works. But when I save it...
2
by: Brian Mitchell | last post by:
Ok, I know this is an elementary question but I have a data grid that is bound to a data table and I can't seem to find a way to match the selected row in the grid with it's respective row in the...
1
by: John | last post by:
Hi When using Table Adapter Configuration Wizard if 'Use SQL Statements' is selected as Command Type, the data table's name in dataset is retained and only its data adapter's select statements...
5
by: Mark | last post by:
Hi - I've a data table that I want to save to an external Access database. I'm interested in sample code that would perform this save. Thanks, Mark (VB.NET, .Net framework 1.0)
1
by: laredotornado | last post by:
Hi, I have a data table on my page (buried amidst other images and extraneous text). I would like to spawn a new window that automatically prints the content of my data table, and only that...
1
by: aritra2008 | last post by:
Hi, Can anybody tell me how can I insert multiple data in a data table of a database using DataGridView control in VB/ASP.Net? It is very urgent for me to know. Kindly anybody help me...
1
by: Limno | last post by:
Can anyone suggest me how to pass datagridview data to database. Process must be like this, if the user enter multiple data into the datagridview after user press "save" button, datagridview data...
4
by: indona | last post by:
hi, i have to enter data from a delimited file into sqlserver database table. i have been able to delimit the file and read the data into a data table, now i want enter the data table contents to...
1
by: BaseballGraphs | last post by:
Hello, I am trying to divide one value from my data table with an associated ID by another value from my data table with a different ID for the same day that the value was added to the data table....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.