Hi,
I have a problem while inserting a row into MS Acess database
I followed the below procedure to insert a row into MS Access
1. Add a Button control to Form1.
2. Right-click Button1, and then click Properties.
3. In the Properties dialog box, set the Text property to Add.
4. Add the following code to the Button1_Click event handler:
Dim i, sno As Integer
Dim sname As String
Dim rw As DataRow
'Add a new row to the Student table.
rw = DataSet11.Table s(0).NewRow
sno = InputBox("Enter the Roll no of the Student:")
sname = InputBox("Enter the Name of the Student:")
rw.Item("SNo") = sno
rw.Item("SName" ) = sname
Try
DataSet11.Table s(0).Rows.Add(r w)
'Update the Student table in the testdb database.
i = OleDbDataAdapte r1.Update(DataS et11)
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
'Displays number of rows updated.
MessageBox.Show ("no of rows updated=" & i)
when i execute the above procedure ,i able to see the inserted row
but,the row did not get inserted in MS Access database....
I think "DataSet11.Tabl es(0).Rows.Add( rw)",this statement tells add a row to the dataset of table in MS Access .Thats why the row is not getting inserted...
if so,
please someone help me to solve this problem...
I have a problem while inserting a row into MS Acess database
I followed the below procedure to insert a row into MS Access
1. Add a Button control to Form1.
2. Right-click Button1, and then click Properties.
3. In the Properties dialog box, set the Text property to Add.
4. Add the following code to the Button1_Click event handler:
Dim i, sno As Integer
Dim sname As String
Dim rw As DataRow
'Add a new row to the Student table.
rw = DataSet11.Table s(0).NewRow
sno = InputBox("Enter the Roll no of the Student:")
sname = InputBox("Enter the Name of the Student:")
rw.Item("SNo") = sno
rw.Item("SName" ) = sname
Try
DataSet11.Table s(0).Rows.Add(r w)
'Update the Student table in the testdb database.
i = OleDbDataAdapte r1.Update(DataS et11)
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
'Displays number of rows updated.
MessageBox.Show ("no of rows updated=" & i)
when i execute the above procedure ,i able to see the inserted row
but,the row did not get inserted in MS Access database....
I think "DataSet11.Tabl es(0).Rows.Add( rw)",this statement tells add a row to the dataset of table in MS Access .Thats why the row is not getting inserted...
if so,
please someone help me to solve this problem...