| | |
Updating a record in an MS Access database file using DataSets
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
Hi.
I'm fairly new to VB.NET programming, and i'm currently developing an application for the sake of experience.
What i know about Visual Basic programming might be considered dangerous, but none the less, i'm trying.
I'm having difficulty getting past the idea of how to update a record in a Microsoft Access 2000 database file. I have no problems inserting, deleting and creating new records in the database, but somehow it seems that there's more to updating a record than what i had expected.
The following code is what i use to collect the data of a specific row in my mdb file, and then displaying the data in the corresponding textbox which i have on my windows form.
I managed to get past that and work myself around in order to fill the respective text boxes on my windows form.
Now the problem i'm facing, is that i have 3 buttons on this form, which should enable me to ADD, DELETE, or UPDATE the record by filling in or editing the text boxes on the form.
So many times have I tried, and so many times have i searched accross the Internet, and I cant seem to resolve this problem.
I want the update method to work like that of the code snippet I provided above, or atleast something similar to that.
Could anyone please help me with this?
Thank you in advance. Really appreciate it.
I'm fairly new to VB.NET programming, and i'm currently developing an application for the sake of experience.
What i know about Visual Basic programming might be considered dangerous, but none the less, i'm trying.
I'm having difficulty getting past the idea of how to update a record in a Microsoft Access 2000 database file. I have no problems inserting, deleting and creating new records in the database, but somehow it seems that there's more to updating a record than what i had expected.
The following code is what i use to collect the data of a specific row in my mdb file, and then displaying the data in the corresponding textbox which i have on my windows form.
VB.NET Syntax (Toggle Plain Text)
Dim con As New OleDb.OleDbConnection Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql As String con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\bin\MY_DATABASE.mdb" con.Open() sql = "SELECT * FROM client WHERE ID = 1" da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds, "ClientList") con.Close() 'filling the corresponding textbox named txtName which I have on my windows form txtName.Text = ds.Tables("ClientList").Rows(0).Item("Name")
I managed to get past that and work myself around in order to fill the respective text boxes on my windows form.
Now the problem i'm facing, is that i have 3 buttons on this form, which should enable me to ADD, DELETE, or UPDATE the record by filling in or editing the text boxes on the form.
So many times have I tried, and so many times have i searched accross the Internet, and I cant seem to resolve this problem.
I want the update method to work like that of the code snippet I provided above, or atleast something similar to that.
Could anyone please help me with this?
Thank you in advance. Really appreciate it.
•
•
•
•
to update Database (vb.net Code)
Dim cb as new oledb.oledbcommandbuilder(da)
ds.tables("yourtablename").rows(rowno).item(columnno)="Value"
ds.tables("yourtablename").rows(rowno).item(columnno)="value"
da.update(ds, "Yourtablename")
'da = dataadapter object
'ds = dataset object
I tried your code, but i keep getting a Microsoft Error report whenever I click the Update button on my windows form.
The error report which I get, is as follows:
Project1.vshost.exe has encountered a problem and needs to close. We are sorry for the inconvenience.
Do you perphaps know what might cause this error report whenever I click the update button?
Try this
There is just two ways to live your life.
One is as though nothing is a miracle.
The other is as if everything is.
One is as though nothing is a miracle.
The other is as if everything is.
![]() |
Similar Threads
Other Threads in the VB.NET Forum
- Previous Thread: office metadata
- Next Thread: ActiveX Control Can't create the o
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array assignment basic binary bing box button buttons center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist editvb.net excel file-dialog firewall folder ftp google hardcopy image images insert isnumericfuntioncall login math memory mobile ms mssqlbackend navigate net networking opacity output passingparameters peertopeervideostreaming picturebox1 port print problemwithinstallation project record reports" save savedialog searchbox serial soap string table tcp temp text textbox timer toolbox trim update updown useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio web wpf





