I m using ADODB+ SQL.
Mine SQL table is
[code=sql]
create database student
use student
create table stu_table(roll int primary key,name varchar(10),
marks int)
[/code][code=sql]
select * from stu_table
[/code]
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--
[code=vbnet]
Private Sub cmbRoll_Selecte dIndexChanged(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles cmbRoll.Selecte dIndexChanged
Try
If con.State = 1 Then
con.Close()
End If
con.Open()
RS.Open("select name,marks from stu_table where roll='" & Me.cmbRoll.Text & "'", con, CursorTypeEnum. adOpenStatic, LockTypeEnum.ad LockBatchOptimi stic)
obj.DataGridVie w1.Item(0, 0).Value = RS.Fields(0).Va lue.ToString
obj.DataGridVie w1.Item(1, 0).Value = RS.Fields(1).Va lue.ToString
Catch ex As Exception
MsgBox(ex.Messa ge)
Finally
If con.State = 1 Then
con.Close()
End If
End Try
End Sub
[/code]
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.
Mine SQL table is
[code=sql]
create database student
use student
create table stu_table(roll int primary key,name varchar(10),
marks int)
[/code][code=sql]
select * from stu_table
[/code]
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--
[code=vbnet]
Private Sub cmbRoll_Selecte dIndexChanged(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles cmbRoll.Selecte dIndexChanged
Try
If con.State = 1 Then
con.Close()
End If
con.Open()
RS.Open("select name,marks from stu_table where roll='" & Me.cmbRoll.Text & "'", con, CursorTypeEnum. adOpenStatic, LockTypeEnum.ad LockBatchOptimi stic)
obj.DataGridVie w1.Item(0, 0).Value = RS.Fields(0).Va lue.ToString
obj.DataGridVie w1.Item(1, 0).Value = RS.Fields(1).Va lue.ToString
Catch ex As Exception
MsgBox(ex.Messa ge)
Finally
If con.State = 1 Then
con.Close()
End If
End Try
End Sub
[/code]
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.