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

Dataset problem

I have the following problem:

I am populating a dataset but, sometimes (NOT always), the
NewRow method works like the Add method.

SetRightDetail.RightDetail.Rows.Clear()
For Each Right In TblRight.Rows
With Right
Detail = SetRightDetail.RightDetail.NewRow() (1)
Detail.Item("PKID") = .Item("PKID") (2)
Detail.Item("Type") = .Item("Type")
SetRightDetail.RightDetail.Rows.Add(Detail) (3)
End With
Next

Following is one example of the results after the lines
1,2,3 are executed:

Right.Item("PKID") Detail.Item("PKID")
NewRow Result

Iter 1:
(1) 1 DBNull
DBNull OK
(2) 1 1
DBNull OK
(3) 1 1
1 OK

Iter 2:
(1) 2 DBNull
DBNull OK
(2) 2 2
2 WRONG
(3) Generates an exception error for
duplicated primary key WRONG

What can I do to avoid the problem?

Thanks in advance,
LDV-ME
Nov 20 '05 #1
9 1137
Cor
Hi Micky,

You can include a find (datarowcollection.find)

something as see it as pseudo
\\\\
dim detail as datarow = SetRightDetail.RightDetail.Rows.find(thekey)
if detail Is nothing then
Detail = SetRightDetail.RightDetail.NewRow()
detail.item(key) = key
SetRightDetail.RightDetail.Rows.Add(Detail)
end if
detail = ............................
////
I hope this helps

Cor

"Miky" <le******@davinci.com> schreef in bericht
news:08****************************@phx.gbl...
I have the following problem:

I am populating a dataset but, sometimes (NOT always), the
NewRow method works like the Add method.

SetRightDetail.RightDetail.Rows.Clear()
For Each Right In TblRight.Rows
With Right
Detail = SetRightDetail.RightDetail.NewRow() (1)
Detail.Item("PKID") = .Item("PKID") (2)
Detail.Item("Type") = .Item("Type")
SetRightDetail.RightDetail.Rows.Add(Detail) (3)
End With
Next

Following is one example of the results after the lines
1,2,3 are executed:

Right.Item("PKID") Detail.Item("PKID")
NewRow Result

Iter 1:
(1) 1 DBNull
DBNull OK
(2) 1 1
DBNull OK
(3) 1 1
1 OK

Iter 2:
(1) 2 DBNull
DBNull OK
(2) 2 2
2 WRONG
(3) Generates an exception error for
duplicated primary key WRONG

What can I do to avoid the problem?

Thanks in advance,
LDV-ME

Nov 20 '05 #2
Thanks for your answer.

The problem is that the datarow isn't physically on the
table (it has been cleared just before entering in the
for...next loop) and the source table contains only 1 row
(it has the same primary key).

It looks like that after Detail is set to the NewRow, it
will point always to the same memory address and
consequently they will change together.

I tried to bypass the Add for the second row and after
everything was OK. The second row (in the source table)
has never been added to the target table.

I tried to use the find getting back only the first row.

Thanks,
LDV-ME.
-----Original Message-----
Hi Micky,

You can include a find (datarowcollection.find)

something as see it as pseudo
\\\\
dim detail as datarow = SetRightDetail.RightDetail.Rows.find(thekey)if detail Is nothing then
Detail = SetRightDetail.RightDetail.NewRow()
detail.item(key) = key
SetRightDetail.RightDetail.Rows.Add(Detail)
end if
detail = ............................
////
I hope this helps

Cor

"Miky" <le******@davinci.com> schreef in bericht
news:08****************************@phx.gbl...
I have the following problem:

I am populating a dataset but, sometimes (NOT always), the NewRow method works like the Add method.

SetRightDetail.RightDetail.Rows.Clear()
For Each Right In TblRight.Rows
With Right
Detail = SetRightDetail.RightDetail.NewRow() (1)
Detail.Item("PKID") = .Item("PKID") (2)
Detail.Item("Type") = .Item("Type")
SetRightDetail.RightDetail.Rows.Add(Detail) (3)
End With
Next

Following is one example of the results after the lines
1,2,3 are executed:

Right.Item("PKID") Detail.Item("PKID")
NewRow Result

Iter 1:
(1) 1 DBNull
DBNull OK
(2) 1 1
DBNull OK
(3) 1 1
1 OK

Iter 2:
(1) 2 DBNull
DBNull OK
(2) 2 2
2 WRONG
(3) Generates an exception error for
duplicated primary key WRONG

What can I do to avoid the problem?

Thanks in advance,
LDV-ME

.

Nov 20 '05 #3
Just a correction to my previous post.

Using the find function I get the same problem.

One way I avoided the problem I put a try...catch when I
was adding the row to the dataset (getting back all the
rows)... but still I would like to understand why.

Thanks again,
LDV-ME.
-----Original Message-----
Thanks for your answer.

The problem is that the datarow isn't physically on the
table (it has been cleared just before entering in the
for...next loop) and the source table contains only 1 row
(it has the same primary key).

It looks like that after Detail is set to the NewRow, it
will point always to the same memory address and
consequently they will change together.

I tried to bypass the Add for the second row and after
everything was OK. The second row (in the source table)
has never been added to the target table.

I tried to use the find getting back only the first row.

Thanks,
LDV-ME.
-----Original Message-----
Hi Micky,

You can include a find (datarowcollection.find)

something as see it as pseudo
\\\\
dim detail as datarow =

SetRightDetail.RightDetail.Rows.find(thekey)
if detail Is nothing then
Detail = SetRightDetail.RightDetail.NewRow()
detail.item(key) = key
SetRightDetail.RightDetail.Rows.Add(Detail)
end if
detail = ............................
////
I hope this helps

Cor

"Miky" <le******@davinci.com> schreef in bericht
news:08****************************@phx.gbl...
I have the following problem:

I am populating a dataset but, sometimes (NOT always),the NewRow method works like the Add method.

SetRightDetail.RightDetail.Rows.Clear()
For Each Right In TblRight.Rows
With Right
Detail = SetRightDetail.RightDetail.NewRow() (1) Detail.Item("PKID") = .Item("PKID") (2)
Detail.Item("Type") = .Item("Type")
SetRightDetail.RightDetail.Rows.Add(Detail) (3)
End With
Next

Following is one example of the results after the lines
1,2,3 are executed:

Right.Item("PKID") Detail.Item("PKID")
NewRow Result

Iter 1:
(1) 1 DBNull
DBNull OK
(2) 1 1
DBNull OK
(3) 1 1
1 OK

Iter 2:
(1) 2 DBNull
DBNull OK
(2) 2 2
2 WRONG
(3) Generates an exception error for
duplicated primary key WRONG

What can I do to avoid the problem?

Thanks in advance,
LDV-ME

.

.

Nov 20 '05 #4
Hi Miky

Thanks for you posting in the group!

We will look into it and reply with more information here.
Please post here if you have any more concerns.
Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 20 '05 #5
Cor
Hi Micky,

When you use a
try
' something
catch
'nothing in it
end try

You never get a real error, that is real bad behaviour.

If you have only one row in one table from a dataset why not just do
ds1.tables(0).rows(0)("myfirstItem") = ds2.tables(0).rows(0)("myfirstItem")
ds1.tables(0).rows(0)("mySecondItem") =
ds2.tables(0).rows(0)("mySecondItem")

And if you are sure the key is only item(0) and the datasets schemas are
equal
for i as integer = 1 to ds1.tables(0).rowcount - 1
ds1.tables(0).rows(0)(i) = ds2.tables(0).rows(0)(i)
next
To do all items in one time.

All typed in this message so watch typos

I hope this helps,

Cor
Just a correction to my previous post.

Using the find function I get the same problem.

One way I avoided the problem I put a try...catch when I
was adding the row to the dataset (getting back all the
rows)... but still I would like to understand why.

Nov 20 '05 #6
Thanks again Cor,

I know it is bad but it was the only way I found to bypass the error.
Actually in the catch I call the sub itself and when returns back to the
parent sub I have the entire dataset in the correct way.

I don't have only one row but I could have between 2 and 100 rows and the
XML schemas are not equals (there are equals elements but in different
positions).

In the application I have other datasets and they work just fine. This is
the first time this problem happened to me, and even more strange, it
happens only the first time the application call the sub... after that, it
works fine.

Thanks again,
LDV-ME.

"Cor" <no*@non.com> wrote in message
news:uj**************@TK2MSFTNGP12.phx.gbl...
Hi Micky,

When you use a
try
' something
catch
'nothing in it
end try

You never get a real error, that is real bad behaviour.

If you have only one row in one table from a dataset why not just do
ds1.tables(0).rows(0)("myfirstItem") = ds2.tables(0).rows(0)("myfirstItem") ds1.tables(0).rows(0)("mySecondItem") =
ds2.tables(0).rows(0)("mySecondItem")

And if you are sure the key is only item(0) and the datasets schemas are
equal
for i as integer = 1 to ds1.tables(0).rowcount - 1
ds1.tables(0).rows(0)(i) = ds2.tables(0).rows(0)(i)
next
To do all items in one time.

All typed in this message so watch typos

I hope this helps,

Cor
Just a correction to my previous post.

Using the find function I get the same problem.

One way I avoided the problem I put a try...catch when I
was adding the row to the dataset (getting back all the
rows)... but still I would like to understand why.


Nov 20 '05 #7
Hi LDV-ME,

To find out whether or not there is another better method to resolve this
problem, would you please make a small sample to demonstrate how to
reproduce the same problem, so that I am able to reproduce the same problem
and perform further research on my side?

If you have further information about this problem, please let me know.
Best regards,

Kevin Sun
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #8
Thanks for your answer.

I tried to create a fast sample, but I cannot reproduce
the problem. As soon as I solve a more urgent problem that
it is stopping the deployment, I will work on reproducing
the problem.

Question: How can I post an attachment to my message from
the web interface, if I need to add files other than the
form to reproduce the error? I cannot use other programs
to access to the newsgroup.

Thanks,
LDV-ME
-----Original Message-----
Hi LDV-ME,

To find out whether or not there is another better method to resolve thisproblem, would you please make a small sample to demonstrate how toreproduce the same problem, so that I am able to reproduce the same problemand perform further research on my side?

If you have further information about this problem, please let me know.

Best regards,

Kevin Sun
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
.

Nov 20 '05 #9
Hi LDV-ME,

You are able to send files to me directly to zh****@microsoft.com. Note to
provide detailed reproducing steps. I cannot reach you by email
le******@davinci.com.
If you have further information about this problem, please let me know.
Best regards,

Kevin Sun
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #10

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

Similar topics

6
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
2
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
2
by: theWizK | last post by:
Hello all. I have noticed that when I generate a strongly-typed dataset from an xml schema that the DataTables that are generated have their constructors marked as internal. What this means is...
4
by: Joerg M. Colberg | last post by:
Hi all, I have a problem when using a DataSet. I am using it to query a SQLServer database as follows. In my code it looks like SqlDataAdapter eDA = new SqlDataAdapter(sqlcmd); // where...
2
by: Dennis | last post by:
Hi, I am hoping I can get some help with a small problem I have run into using C#. U have an XML file that I load into a Dataset and then display this in a Datagrid. No problems doing this at all....
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
0
by: Bob Davies | last post by:
Hi I have a webservice that retrieves data from a database, this is then returned to the calling client application built in windows forms within a dataset, however upon attempting to create...
2
by: Carl Summers | last post by:
I have a table in an Access database that has no sort applied in Access. When I fill a dataset with data from that table (the entire one dimensional table) my dataset is sorted differently than...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
8
by: Harry Strybos | last post by:
Visual Studio 2005 - SP1 - VB.Net on WinXP SP2 I add a typed dataset to my solution and get the following errors : Error 1 sub 'ReadXmlSerializable' cannot be declared 'Overrides' because it...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.