473,799 Members | 3,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to save datagridview data to a sql table?

347 Contributor
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 1591

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

Similar topics

1
1436
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 experience with saving bulk data?
0
2694
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 between those actions into Oracle database into long row field, it doesn´t. Below is some code.
2
2716
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 underlying data table. If the rows in the grid are in the same order as the rows in the table then I can use the Datagrid.CurrentRowIndex to return the same row from the data table. But if the user sorts the data in the grid then the row order...
1
2786
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 are replaced. If however 'Create new stored procedures' is selected as Command Type, the data table name in replaced by the name of the newly created select stored procedure. Problem with this is that the data table's name needs to be put back...
5
5822
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
3484
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 content. The tricky part is the ordering of the table may not be the same as when the page was loaded. I recently discovered the virtues of JQuery and its tablesorter plugin (http://motherrussia.polyester.se/ jquery-plugins/tablesorter/), so it is...
1
1567
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 with a code snippet. Aritra.
1
2209
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 must be passed to database. Need C# code in windows application. It should have some comboxbox control in datagridview. Thanks in Advance.
4
34484
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 sqlserver. some help in this matter...if possible code for moving data from data table to the database....would be really helpful. thanks in advance.
1
2646
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. I update my data table daily with several values that have different IDs that label the value type. Certain of the values I add to my data table also have a value of 0. Therefore, if I want to divide one value by another, I have to ensure that...
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10260
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9078
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.