dataset name

B

Bob Day

Using vs2003, vb net.

Why does DS>DataSetName return the base name DS_Caller_Base instead of the
instantiated Name of DataSet1? See '**** for the line in question.

Friend sub1

' instantiate new dataset

dim DataSet1 as new DS_Caller_Base

' pass new dataset to sub2

sub2(DataSet1)

end sub

Friend sub2(ByRef DS As DS_Caller_Base)

' Note that the DataSetName below give its base name (not sure why),
instead of the name of the passed instantiated dataset.

dim x as string = DS.DataSetName '*****************

' why does x = DS_Caller_Base and not x = DataSet1

end sub

Thanks!

Bob
 
G

Gary Chang

Hi Bob,

Thanks for using Microsoft MSDN Managed Newsgroup.
My name is Gary, and I will be assisting you on this issue.

First of all, I would like to confirm my understanding of your issue.

From your description, I understand that when you defended as:
Dim DataSet1 as new DS_Caller_Base 'assume as DataSet
the DataSet1.DataSetName = "DS_Caller_Base", you wonder why is not the
"DataSet1"

Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.


Based on my knowledge, the "DataSet1" is the identity name(ID) of your
instantiated DataSet object(in other words it is your DataSet variable's
name, it is only recognized within your program code and just visible to
the compiler), it is not the DataSet object(represent by DataSet1)'s name.

The DataSet1object has its own default name(this is a property of the
DataSet class)(DS_Caller_Base"("NewDataSet"), you can change its default
name by
e.g. DataSet1.DataSetName = "My DataSet"


Hope I can make my words understood easily!

Thank!

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.
--------------------
 
B

Bob Day

Yes you understand my question. Your answer is correct, but doesn't make
much sense. Asside from ".DataSetName" being a confusing way to mean
".DataSetBaseName", how do I get the instantiated dataset name?

The way ".DataSetName" works is like saying:
Dim x as integer
dim y as string = x.VarialbleName
y would return "Integer".

I am instantiating a Component Designer file that has many DataSets in it,
so it is not feasible for me to go through and try to name each instantiated
dataset one by one with some line like:
DataSet1.DataSetName = "DataSet1"

So, how can I return the instantiated DataSet1 name? I don't see anyway.

Thanks!

Bob
 
G

Gary Chang

Hi Bob,

Thanks for your quickly reply!

As my last post description, the instantiated DataSet object's
name(DataSet1) is just a symbol to represent the DataSet object in your
code(design time).

However the ".DataSetName" is a *property* of the DataSet class, the
default value of this property is its class name, which is defined in MSDN.
That is to say, it returns the class name of a variable by default, not
variable name. we can assign it a meaningful name and use it at run-time.
I am instantiating a Component Designer file that has many DataSets in it,
so it is not feasible for me to go through and try to name each instantiated
dataset one by one with some line like:
DataSet1.DataSetName = "DataSet1"

So, how can I return the instantiated DataSet1 name? I don't see anyway.

So there is no easy ways to return the instantiated object's name(DataSet1)
Automatically. In order to get a variable's name, we need to set its
DataSetName property manually in coding. Since the class is developed by
you, you could also add a customized property to store this name by
yourself.

Does that answer your question? If there is any unclear, please feel free
to post here.


Thanks!

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.
--------------------
 

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