| | |
Add New Record
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2008
Posts: 9
Reputation:
Solved Threads: 0
hi,
I have Created a vb.net Application with MS ACCESS DATABASE, everything is working fine, But, There is a small problem . Everytime i ADD a new record it saves succesfully
but i can only view that particular saved data only after restarting the application..Pls Help me
******************************************************
Imports System.Data
Public Class frmdetail
Inherits System.Windows.Forms.Form
Dim inc As Integer
Dim maxrows As Integer
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Private Sub frmdetail_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source = C:\Documents and Settings\Acer\Desktop\CounsellingSystem\counselling.mdb"
con.Open()
sql = "select * from counselling"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "counselling")
con.Close()
maxrows = ds.Tables("counselling").Rows.Count
inc = -1
End Sub
Private Sub navigaterecords()
txtname.Text = ds.Tables("counselling").Rows(inc).Item(1)
txtcname.Text = ds.Tables("counselling").Rows(inc).Item(2)
txtnpos.Text = ds.Tables("counselling").Rows(inc).Item(3)
End Sub
Private Sub btncommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncommit.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsnewrow As DataRow
dsnewrow = ds.Tables("counselling").NewRow()
dsnewrow.Item(1) = txtname.Text
dsnewrow.Item(2) = txtcname.Text
dsnewrow.Item(3) = txtnpos.Text
ds.Tables("counselling").Rows.Add(dsnewrow)
da.Update(ds, "counselling")
MsgBox("New Record Added!")
Endclass
End Class
***************************************************
I have Created a vb.net Application with MS ACCESS DATABASE, everything is working fine, But, There is a small problem . Everytime i ADD a new record it saves succesfully
but i can only view that particular saved data only after restarting the application..Pls Help me
******************************************************
Imports System.Data
Public Class frmdetail
Inherits System.Windows.Forms.Form
Dim inc As Integer
Dim maxrows As Integer
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Private Sub frmdetail_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source = C:\Documents and Settings\Acer\Desktop\CounsellingSystem\counselling.mdb"
con.Open()
sql = "select * from counselling"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "counselling")
con.Close()
maxrows = ds.Tables("counselling").Rows.Count
inc = -1
End Sub
Private Sub navigaterecords()
txtname.Text = ds.Tables("counselling").Rows(inc).Item(1)
txtcname.Text = ds.Tables("counselling").Rows(inc).Item(2)
txtnpos.Text = ds.Tables("counselling").Rows(inc).Item(3)
End Sub
Private Sub btncommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncommit.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsnewrow As DataRow
dsnewrow = ds.Tables("counselling").NewRow()
dsnewrow.Item(1) = txtname.Text
dsnewrow.Item(2) = txtcname.Text
dsnewrow.Item(3) = txtnpos.Text
ds.Tables("counselling").Rows.Add(dsnewrow)
da.Update(ds, "counselling")
MsgBox("New Record Added!")
Endclass
End Class
***************************************************
•
•
Join Date: Dec 2008
Posts: 9
Reputation:
Solved Threads: 0
•
•
•
•
yes this happens because the control you are using is not eligible to update its data everytime. So what do you need to do is to update the data that is shown every time that you add a row.
you can do this by executing the same code that you have written.
Happy X-mas & Coding!
Execute Control!>.....could you pls give me an example ?
Merry X-Mas n Year 09 dude.
![]() |
Similar Threads
- How to add a record in database using a dataset (VB.NET)
- Help needed with code to add record to access database using VB 2005 (Visual Basic 4 / 5 / 6)
- Beginner: how to add new record into database??? (VB.NET)
- Inserting a new Access Database Record (VB.NET)
- This Blank Database Record! (C#)
- passing empty string to SqlCommand.Parameter.Add (VB.NET)
- add record in table with button and textbox (Visual Basic 4 / 5 / 6)
- Adding a record from a table to another (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Save password...plz help
- Next Thread: Creation of *.exe from VS2005
| Thread Tools | Search this Thread |
.net .net2008 2008 access account advanced application array basic beginner browser button buttons center click code combo cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic excel exists fade filter forms ftp generatetags html images input insert intel internet listview map mobile module monitor msaccess net number objects open panel passingparameters pdf picturebox picturebox2 port position print printing problem regex right-to-left save search searchvb.net select serial settings shutdown socket sqldatbase sqlserver survey table temperature textbox timer timespan transparency txttoxmlconverter update user usercontol vb vb.net vb.netformclosing()eventpictureboxmessagebox vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode xml year





