By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,031 Members | 1,334 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,031 IT Pros & Developers. It's quick & easy.

variable assignments - classes & objects

P: n/a
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


Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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
Nov 21 '05 #2

P: n/a
Cor, I'm sorry, but I don't follow what you are saying.

Jeremy

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
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

Nov 21 '05 #3

P: n/a
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
Nov 21 '05 #4

P: n/a
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 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.

Yes, that is correct.

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.


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
Nov 21 '05 #5

P: n/a
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
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.