473,387 Members | 1,520 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,387 software developers and data experts.

duplicate records being recorded

Still working out a few bugs in a survey program I'm writing. The way I
have it configured is as each survey is completed, the dataset is updated.
When the program is closed, the database itself is updated. However, when I
check the database table, there are some answers that are duplicated two and
three times.

Here are some snippets...

//This sub is called on the last page of the survey when the "Finish" button
is clicked.
Sub GatherAndUpdateAnswers()
//there is some code before this that gathers all the answers and assigns
them to variables
dim newrecord as datarow = mainform.dssurveydata1.survey_data.newrow
newrecord(0) = QuestionOneAnswer
newrecord(2) = QuestionTwoAnswer
//repeats like this until twelve

mainform.dssurveydata1.survey_data.rows.add(newrec ord)

end sub

Sub UpdateData()
dim pdsInsertedRows as system.data.dataset
pdsInsertedRows = mainform.dssurvey_data1.getchanges(datarowstate.ad ded)
mainform.oledbdataadapter1.update(pdsInsertedRows)
end sub

Private Sub Form1_Closing(...)
Call UpdateData()
end sub

When the "Finish" button is clicked on the last form,
GatherAndUpdateAnswers() is called.
Nov 21 '05 #1
4 912
Another problem discovered...

Some of the text fields in the database that require some longer answers are
cutting off the data. I have the appropriate fields set to "Memo", which is
not supposed to have a default length, but it's still happening. Any ideas?

"Martin Williams" <ma*******@comcast.net> wrote in message
news:1a********************@comcast.com...
Still working out a few bugs in a survey program I'm writing. The way I
have it configured is as each survey is completed, the dataset is updated.
When the program is closed, the database itself is updated. However, when I check the database table, there are some answers that are duplicated two and three times.

Here are some snippets...

//This sub is called on the last page of the survey when the "Finish" button is clicked.
Sub GatherAndUpdateAnswers()
//there is some code before this that gathers all the answers and assigns
them to variables
dim newrecord as datarow = mainform.dssurveydata1.survey_data.newrow
newrecord(0) = QuestionOneAnswer
newrecord(2) = QuestionTwoAnswer
//repeats like this until twelve

mainform.dssurveydata1.survey_data.rows.add(newrec ord)

end sub

Sub UpdateData()
dim pdsInsertedRows as system.data.dataset
pdsInsertedRows = mainform.dssurvey_data1.getchanges(datarowstate.ad ded) mainform.oledbdataadapter1.update(pdsInsertedRows)
end sub

Private Sub Form1_Closing(...)
Call UpdateData()
end sub

When the "Finish" button is clicked on the last form,
GatherAndUpdateAnswers() is called.

Nov 21 '05 #2
Martin,

You are aware of the fact that the getchanges create a copy dataset of the
changes.
The original dataset will in this case not be affected by the build in
acceptchanges from the dataadapter.

Cor
Nov 21 '05 #3
So, do I change my UpdateAnswers sub to just AcceptChanges from the dataset?
I thought the dataset was a disconnected view of the database itself, but
the program updates the database just from adding rows to the dataset. If
it works, it works, I'm just trying to get a handle on it.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Ok**************@TK2MSFTNGP12.phx.gbl...
Martin,

You are aware of the fact that the getchanges create a copy dataset of the
changes.
The original dataset will in this case not be affected by the build in
acceptchanges from the dataadapter.

Cor

Nov 21 '05 #4
Martin,

The acceptchanges set all the rowstate to done, what is a function as well
from the dataadapter, however you do that on the copy dataset getchanges.

So you can try to set that after the update.

As sample
\\\
if ds.haschanges then
ds.update(ds.getchanges)
ds.acceptchanges
end if
///
I hope this helps

Cor
Nov 21 '05 #5

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

Similar topics

2
by: george | last post by:
This is like the bug from hell. It is kind of hard to explain, so please bear with me. Background Info: SQL Server 7.0, on an NT box, Active Server pages with Javascript, using ADO objects. ...
29
by: Scott Marquardt | last post by:
Consider a table that holds Internet browsing history for users/machines, date/timed to the minute. The object is to tag all times that are separated by previous and subsequent times by x number of...
2
by: ms | last post by:
Access 2000: I am trying to delete duplicate records imported to a staging table leaving one of the duplicates to be imported into the live table. A unique record is based on a composite key of 3...
6
by: 6thirty | last post by:
Hi, I've created a stocktaking database using Access XP. This is indexed by two fields - part number and shelf location. I am currently inputting all the data via a form. When I have entered a...
2
by: Carroll | last post by:
I'm looking for a way in SQL to find duplicate records in a single table, that are the same based on 3 columns, regardless of what is in the other columns in the duplicate records. I would like to...
7
by: ebindia0041 | last post by:
This is like the bug from hell. It is kind of hard to explain, so please bear with me. Background Info: SQL Server 7.0, Asp.net 1.1 with c# I'm inserting simple records into a table. But one...
2
by: nethravathy | last post by:
Hi, The following table namely elcbtripselect contains 5147 records.I want to know wether this table contains duplicate records or not. I tried with following query 1)SELECT...
3
Stang02GT
by: Stang02GT | last post by:
Somehow i got a duplicate recorded into one of my tables. Is there any way I can edit them, or will I have to delete both of the records and re-insert the correct records?
2
by: nomvula | last post by:
hi guys i need some help to duplicate records on my form datasheet: here's the example of my form results: ClientLookup DateCaptured ForecastDate Description ForecastQuantity Forecast Actual UJ...
1
by: xraive | last post by:
I have a problem with this. Currently I am trying Allen's code and i am not successful. Current Design Table1 (Main Form) TravelID (PK) ApprovedBY EntreredBy BudgetCode ExpenseCode
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.