473,403 Members | 2,354 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,403 software developers and data experts.

Problem adding new row in Access Table

RPK
I am using following code to Add New Record in a Table (Temp in this case). I
want to save new record with this method i.e., non-SQL. It is not commiting
changes. The "Update" statement has errors.
'Initialize Data Adapter and Data Table Objects
TempDA.Fill(TempDS, "Temp")
TempDT = TempDS.Tables("Temp") 'Temp is the name of table
'Store to Temporary Table
'Start Connection
If Cn.State = ConnectionState.Closed Then
Call StartConnection()
End If

TempNewRow = TempDT.NewRow()
TempNewRow("Pno") = NewPNo
TempNewRow("PLName") = tab1_namepl

'Add the new row
TempDT.Rows.Add(TempNewRow)

'Commit Changes
TempDS.AcceptChanges()

dsChanges = TempDS.GetChanges
TempDA.Update(dsChanges, "Temp")

'Increment Permit Number
NewPNo = NewPNo + 1
Cn.Close()

If TempDS.HasChanges(DataRowState.Added) Then
MsgBox("Record successfully saved.", MsgBoxStyle.OKOnly,
"Success")
End If
Please also let me know which method for "Saving" record is fast (non-SQL).
Feb 8 '06 #1
3 1402
Hi,

When you call TempDS.AcceptChanges it marks all the records as
unchanged. So dsChanges will not get any records.

Ken
---------------------
"RPK" <RP*@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
I am using following code to Add New Record in a Table (Temp in this case).
I
want to save new record with this method i.e., non-SQL. It is not
commiting
changes. The "Update" statement has errors.
'Initialize Data Adapter and Data Table Objects
TempDA.Fill(TempDS, "Temp")
TempDT = TempDS.Tables("Temp") 'Temp is the name of table
'Store to Temporary Table
'Start Connection
If Cn.State = ConnectionState.Closed Then
Call StartConnection()
End If

TempNewRow = TempDT.NewRow()
TempNewRow("Pno") = NewPNo
TempNewRow("PLName") = tab1_namepl

'Add the new row
TempDT.Rows.Add(TempNewRow)

'Commit Changes
TempDS.AcceptChanges()

dsChanges = TempDS.GetChanges
TempDA.Update(dsChanges, "Temp")

'Increment Permit Number
NewPNo = NewPNo + 1
Cn.Close()

If TempDS.HasChanges(DataRowState.Added) Then
MsgBox("Record successfully saved.", MsgBoxStyle.OKOnly,
"Success")
End If
Please also let me know which method for "Saving" record is fast
(non-SQL).

Feb 8 '06 #2
RPK
Ken,

Please illustrate the lines where the changes are needed.

Thanks.

----------------------------------------------------------------

"Ken Tucker [MVP]" wrote:
Hi,

When you call TempDS.AcceptChanges it marks all the records as
unchanged. So dsChanges will not get any records.

Ken
---------------------
"RPK" <RP*@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
I am using following code to Add New Record in a Table (Temp in this case).
I
want to save new record with this method i.e., non-SQL. It is not
commiting
changes. The "Update" statement has errors.
'Initialize Data Adapter and Data Table Objects
TempDA.Fill(TempDS, "Temp")
TempDT = TempDS.Tables("Temp") 'Temp is the name of table
'Store to Temporary Table
'Start Connection
If Cn.State = ConnectionState.Closed Then
Call StartConnection()
End If

TempNewRow = TempDT.NewRow()
TempNewRow("Pno") = NewPNo
TempNewRow("PLName") = tab1_namepl

'Add the new row
TempDT.Rows.Add(TempNewRow)

'Commit Changes
TempDS.AcceptChanges()

dsChanges = TempDS.GetChanges
TempDA.Update(dsChanges, "Temp")

'Increment Permit Number
NewPNo = NewPNo + 1
Cn.Close()

If TempDS.HasChanges(DataRowState.Added) Then
MsgBox("Record successfully saved.", MsgBoxStyle.OKOnly,
"Success")
End If
Please also let me know which method for "Saving" record is fast
(non-SQL).


Feb 8 '06 #3
Hi,

dsChanges = TempDS.GetChanges
TempDA.Update(dsChanges, "Temp")

'Commit Changes
TempDS.AcceptChanges()

Ken
----------------
"RPK" <RP*@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
Ken,

Please illustrate the lines where the changes are needed.

Thanks.

----------------------------------------------------------------

"Ken Tucker [MVP]" wrote:
Hi,

When you call TempDS.AcceptChanges it marks all the records as
unchanged. So dsChanges will not get any records.

Ken
---------------------
"RPK" <RP*@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
>I am using following code to Add New Record in a Table (Temp in this
>case).
>I
> want to save new record with this method i.e., non-SQL. It is not
> commiting
> changes. The "Update" statement has errors.
>
>
> 'Initialize Data Adapter and Data Table Objects
> TempDA.Fill(TempDS, "Temp")
> TempDT = TempDS.Tables("Temp") 'Temp is the name of table
>
>
> 'Store to Temporary Table
> 'Start Connection
> If Cn.State = ConnectionState.Closed Then
> Call StartConnection()
> End If
>
> TempNewRow = TempDT.NewRow()
> TempNewRow("Pno") = NewPNo
> TempNewRow("PLName") = tab1_namepl
>
> 'Add the new row
> TempDT.Rows.Add(TempNewRow)
>
> 'Commit Changes
> TempDS.AcceptChanges()
>
> dsChanges = TempDS.GetChanges
> TempDA.Update(dsChanges, "Temp")
>
> 'Increment Permit Number
> NewPNo = NewPNo + 1
> Cn.Close()
>
> If TempDS.HasChanges(DataRowState.Added) Then
> MsgBox("Record successfully saved.", MsgBoxStyle.OKOnly,
> "Success")
> End If
>
>
> Please also let me know which method for "Saving" record is fast
> (non-SQL).


Feb 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Filips Benoit | last post by:
Dear All, W2000 Office2000 Access adp SQLserver DB Problem: Adding a new property for a company in the subform. The FIRST time I Select a property in combobox CPROP_PRP_ID the subform act
1
by: Anatoly | last post by:
Hi everybody, I am writing a scheduling system that has appointments table. For each appointment I am adding a new record that has EventID and ClientID. Each event has capacity that needs to be...
8
by: Bri | last post by:
Greetings, I'm having a very strange problem in an AC97 MDB with ODBC Linked tables to SQL Server 7. The table has an Identity field and a Timestamp field. The problem is that when a new record...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
17
by: radio1 | last post by:
Configuration: Access 2002 and SQL Server 2000 using a .ADP Project. I would VERY MUCH appreciate anyone's input into this problem I'm having. I have a form in Access that does not permit...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.