473,490 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Update Database with Changes made to the DataGridView

95 New Member
I m using ADODB+ SQL.

Mine SQL table is
Expand|Select|Wrap|Line Numbers
  1. create database student
  2. use student
  3.  
  4. create table stu_table(roll int primary key,name varchar(10),
  5. marks int)
  6.  
Expand|Select|Wrap|Line Numbers
  1. select * from stu_table
  2.  
FORM1-
On form1 I have Combobox named cmbroll and DataGriDview
In the combroll I retrieved all the roll that are in the database on the form1_load.
When I select roll 1 from cmbroll then in Gridview Corresponding name & marks are displayed.

And the Foll. Code Retrives the data From the Database into the dataGridview--
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbRoll_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbRoll.SelectedIndexChanged
  2. Try
  3. If con.State = 1 Then
  4. con.Close()
  5.  
  6. End If
  7. con.Open()
  8. RS.Open("select name,marks from stu_table where roll='" & Me.cmbRoll.Text & "'", con, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockBatchOptimistic)
  9.  
  10. obj.DataGridView1.Item(0, 0).Value = RS.Fields(0).Value.ToString
  11. obj.DataGridView1.Item(1, 0).Value = RS.Fields(1).Value.ToString
  12. Catch ex As Exception
  13. MsgBox(ex.Message)
  14. Finally
  15. If con.State = 1 Then
  16. con.Close()
  17. End If
  18.  
  19. End Try
  20. End Sub
  21.  
After retreiving records into the GridView I want that if i change Name & Marks in GriDview then on Update table these chnages are also Reflected into the Database.bUt i m not getting from where to start.
Jun 15 '08 #1
0 1310

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

Similar topics

3
11743
by: thomasp | last post by:
I know this is a vague question, but I am not sure what information to give. I am using VB2005 beta and the datagridview is pulling data from one of three tables in an Access database. For some...
1
3112
by: Joaquin | last post by:
OK, I hate myself for asking this, it's the worst question I have ever asked but it's worse not to ask: ¿How do I update a datatable in vs 2005? I mean, I am using a typed dataset, a...
16
3458
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
5
2138
by: explode | last post by:
I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new oledbDataAdapter with insert update select and delete commads. I also added that commands can...
3
3071
by: =?Utf-8?B?THVib21pcg==?= | last post by:
Hi, I have a DataGridView that displays data from one table from database. I didn’t implement any my code, I just used wizard to do all the work with DatagridView populating. Visual Studio...
3
2917
by: sampalmer21 | last post by:
Hi, If I update a cell in the DataGridView control, I use the DataAdapter.Update(DataTable) method to update the database, but when I restart the application my changes are not in the database....
0
1550
by: =?Utf-8?B?anVsaW8=?= | last post by:
I am trying to use Update to save changes made on two DataGridView's to two tables with a FK relationship. I say private void bUpdate_Click(object sender, EventArgs e) { try { ...
1
2348
by: amitjaura | last post by:
Well i have a datagridview in my application and i want it to reflect any changes made in server database instantly with some trigger or so? I have a choice to use timer and get the desired results...
1
4538
by: adsaca | last post by:
database: MySQL i use connector i have two tables with the following contents: tbl_user_info user_id(Primary Key) fname lname
0
7108
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
6967
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
7142
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
7181
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...
1
6847
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
7352
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
4565
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
618
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.