473,803 Members | 3,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Record not adding to the database

2 New Member
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.EventArg s) Handles MyBase.Load
Try
conString = "User ID=;Password=;D ata Source=C:\VBPro ject\SasloBilli ng\SASLO-Billing.mdb;Pro vider=Microsoft .Jet.OLEDB.4.0; Persist Security Info=False" ';Initial Catalog=ClientI ndex"
sqlString = "Select * from ClientIndex"
dsClient = New DataSet
daClient = New OleDb.OleDbData Adapter(sqlStri ng, conString)
daClient.Fill(d sClient, "ClientInde x")
Catch exLoad As Exception
MsgBox(exLoad.M essage)
End Try
End Sub

Private Sub btnSave_Click(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnSave.Click
Try
rowClient = dsClient.Tables ("ClientIndex") .NewRow
rowClient("File No") = txtFileNo.Text
rowClient("Main File") = txtFileNo.Text
rowClient("PCFi le") = "No PC"
dsClient.Tables ("ClientIndex") .Rows.Add(rowCl ient)
'dsClient.Accep tChanges()
daClient.Update (dsClient,"Clie ntIndex"))
MsgBox("Record Added Sucessfully")
Catch exSave As Exception
MsgBox(exSave.M essage)
End Try
End Sub
Dec 29 '06 #1
3 1359
kenobewan
4,871 Recognized Expert Specialist
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
benkollam
2 New Member
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(B yVal sender As System.Object, ByVal e As System.EventArg s) Handles btnSave.Click
Try

DAClient.Update (Client1, "ClientInde x")
Catch exUpdate As Exception
MsgBox(exUpdate .Message)
End Try
End Sub
Dec 31 '06 #3
kenobewan
4,871 Recognized Expert Specialist
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
4666
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 field to start. If I edit that field and then click on the new record button in the navigation buttons, the form goes to a new record and each field has the default value of the previous record. If I put the focus in any field to start, edit that...
5
3348
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 I'm adding a customer. The Customer fields are mostly foreign keys that refer to primary keys in other tables, left join instead of junction tables at this point. So, when I want to add a customer record, I also need to add records to the other...
22
18818
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. The system is client/server, multiusers based. The MDBs are using record locking. Here is part of the code: Dim wkSpace As Workspace, db As Database Dim rstTrans As DAO.Recordset Set wkSpace = DBEngine.Workspaces(0)
10
12721
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 certain that MyVar will be set to the key-field value that was created when the Append query ran. Now, there are other ways to do it - I know - that will ensure you 'nab' the correct record. But I was wondering
1
1464
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") RsLibBuild.ActiveConnection = conn RsLibBuild.LockType = 2 RsLibBuild.CursorType = 1 RsLibBuild.Open "select * from tblbuilding where building_name='" & request.Form ("buildingname") & "' and area_name='" & request.Form ("areaname") & "' and...
0
9700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10546
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.