473,323 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Record not adding to the database

Hi,
I have problem updating the changes in the dataset to the database. I am using an Access database and following is the code used for adding a new row. Please help

Private Sub ClientAdd_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
conString = "User ID=;Password=;Data Source=C:\VBProject\SasloBilling\SASLO-Billing.mdb;Provider=Microsoft.Jet.OLEDB.4.0;Persi st Security Info=False" ';Initial Catalog=ClientIndex"
sqlString = "Select * from ClientIndex"
dsClient = New DataSet
daClient = New OleDb.OleDbDataAdapter(sqlString, conString)
daClient.Fill(dsClient, "ClientIndex")
Catch exLoad As Exception
MsgBox(exLoad.Message)
End Try
End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Try
rowClient = dsClient.Tables("ClientIndex").NewRow
rowClient("FileNo") = txtFileNo.Text
rowClient("MainFile") = txtFileNo.Text
rowClient("PCFile") = "No PC"
dsClient.Tables("ClientIndex").Rows.Add(rowClient)
'dsClient.AcceptChanges()
daClient.Update(dsClient,"ClientIndex"))
MsgBox("Record Added Sucessfully")
Catch exSave As Exception
MsgBox(exSave.Message)
End Try
End Sub
Dec 29 '06 #1
3 1343
kenobewan
4,871 Expert 4TB
Does your dataset load initially? Do you need to open and close your connections to the db? Do you receive an error message?

Essentially, I believe that you need to create a new object and then update the dataset with that - not try to update the dataset directly. Have a look at this:
How to Add a New Record

Hope that this helps.
Dec 29 '06 #2
Does your dataset load initially? Do you need to open and close your connections to the db? Do you receive an error message?

Essentially, I believe that you need to create a new object and then update the dataset with that - not try to update the dataset directly. Have a look at this:
How to Add a New Record

Hope that this helps.
Yes. Dataset is loading initially. I dont think there is no need open and close connections to the db. I am not receiving the error messages. I have same problem with modifying records too. Changes are reflecting withing the dataset. ie, if i navigate thru the recordset the changes are still there. But these changes are not seen in the database. Again no error message.
Following is the update statement used.

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Try

DAClient.Update(Client1, "ClientIndex")
Catch exUpdate As Exception
MsgBox(exUpdate.Message)
End Try
End Sub
Dec 31 '06 #3
kenobewan
4,871 Expert 4TB
I don't see your update SQL statement. What I believe is happening is that your database is not being updated, as trying to update it through the data adapter won't work.

Hope that this helps.
Jan 1 '07 #4

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

Similar topics

15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
5
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
10
by: MLH | last post by:
Suppose, in a multi-user environment, you have append query SQL in a VBA procedure that looks like INSERT INTO MyTable... and the next line reads MyVar=DMax("","MyTable... You can never be...
1
by: raaaz | last post by:
Hi dears, I am adding a record in Access database using AddNew method of recordset. here is the code of the page .. <% Set RsLibBuild = Server.CreateObject ("ADODB.Recordset")...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.