variable assignments - classes & objects

J

Jeremy

I have some classes which contain a datarow as a property. In application
code, I sometimes dim a "shortcut variable" to simplify code.

The problem is, sometimes values seem to vanish. That is, they seem to be
there, but never arrive in the database. It's as if values set using the
shortcut var are in some shadowy copy of the datarow -- seemingly present
when demanded by the debugger, but absent when passed into the update
command.

My understanding is that the variable r (below) is really a pointer to the
original instance, and when I do r.item("fld") = "fred", the original row is
changed. Am I wrong here?

An

The class:
public class myClass
property myRow as datarow
....
end class

In the application:

dim myInstance as new myClass

public sub dosomething
dim r as datarow = myinstance.myrow
... code using r ...
end sub
 
C

Cor Ligthert

Jeremy,

As far as I can see it, are you setting the of your new variable "r" which
is a reference to the reference of myinstance.row. I miss a lot of code, so
I assume you did that express because now it is in my opinion because of 2
reasons nothing what you are referening to.

Cor
 
C

Cor Ligthert

Jeremy,
Cor, I'm sorry, but I don't follow what you are saying.

I almost as well not, the text from my answer is lousy.

However, your question is difficult to answer. I assume that I know what you
want to say. For me is the text from your message unclear because of a lot
of text, from what I don't directly see the relation to question, and maybe
am I answering even a wrong question.

However, I try it again and do it as well than line by line in your message,
to overcome that it is still unclear.

..............New text
As far as I can see, are you setting the reference of your new variable "r"
which is only a reference to an object, the same as to the original
reference to the object myinstance.row".

I miss a lot of code, so I assume you did that express. Because as it is
now, is the result of your code in my opinion due to two reasons always
nothing.
..............

Your text.
I have some classes which contain a datarow as a property. In application
code, I sometimes dim a "shortcut variable" to simplify code.

I assume that you want do the same as a "with" and set a "reference" to the
original datarow by creating a new variable.
The problem is, sometimes values seem to vanish. That is, they seem to be
there, but never arrive in the database. It's as if values set using the
shortcut var are in some shadowy copy of the datarow -- seemingly present
when demanded by the debugger, but absent when passed into the update
command.

It is really vanishing for me, some kind of vaporising, however, what you
mean with this in relation to your complete message, is unclear for me.
My understanding is that the variable r (below) is really a pointer to the
original instance, and when I do r.item("fld") = "fred", the original row
is changed. Am I wrong here?

This part I could answer. The reference is set to the same address/pointer
(whatever you name) it, so what you do is changing the value of
r.item("fld") in "fred" what is the same as TheOriginalDataRow.item("fld") =
"fred"
The class:
public class myClass
property myRow as datarow
...
end class

In the application:

dim myInstance as new myClass

public sub dosomething
dim r as datarow = myinstance.myrow
... code using r ...
end sub

What you want to show with this code is a complete mistory for me. A Sub
that has no passed value and a value that comes directly from the air.

Cor
 
J

Jeremy

Cor, the question I'm asking is related to questions I've been asking for
the last week. I've posted code, but haven't gotten responses, so I'm
trying to keep the msgs small so someone will actually read & answer. The
result of course is an incomplete picture.

Comments below.

....>
I assume that you want do the same as a "with" and set a "reference" to
the original datarow by creating a new variable.
Yes, that is correct.
It is really vanishing for me, some kind of vaporising, however, what you
mean with this in relation to your complete message, is unclear for me.

The root problem is that when I execute an adapter.update, some values
present in my datarow are posted to the database, and some are not. I'm
using an oledbcommandbuilder together with adapter, dataset, and datatable.
My app loads an existing row & displays it correctly on a form (not bound).
I modify some text boxes, save the values into my datarow, then try to
perform an update. The one and only row in the table in the dataset has the
changed values, if I can believe the command window. The adapter.update
executes without error. Some of the changed values appear in the database,
but some do not. I am completely baffled & am going down all kinds of
unlikely paths, but having no success.

Jeremy
 
C

Cor Ligthert

Jeremy,

There is from the information I get from you now only one thing that I can
think about.
The root problem is that when I execute an adapter.update, some values
present in my datarow are posted to the database, and some are not. I'm
using an oledbcommandbuilder together with adapter, dataset, and
datatable.

Do you change datacolumnnames or create new ones during the route that you
described.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top