Access DataSet Name-Property

M

Michael Maes

Hi,

I feel like a "novice" today.....
I'm creating my own (typed) DataSet-Classes and for one method I need the DataSets Instance-Name (not Class-Name).
It seems like, however, that the (name)-"Property" of components isn't accessible.

How do I retreive it's instance-name?

TIA,


Michael
 
M

Miha Markic [MVP C#]

Hi Michael,

Read this thread:
http://groups.google.com/groups?hl=...TF-8&q=get+name+of+component+group%3A*dotnet*

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Hi,

I feel like a "novice" today.....
I'm creating my own (typed) DataSet-Classes and for one method I need the
DataSets Instance-Name (not Class-Name).
It seems like, however, that the (name)-"Property" of components isn't
accessible.

How do I retreive it's instance-name?

TIA,


Michael
 
M

Michael Maes

Hi Miha,

Thanks for your concern.

However: this thread isn't a solution to my issue because of two reasons:

° I (also) need the the instance-name in Design-Time
° DataSets aren't added to the 'components' IContainer - Collection.

I think I need another approach.....

Regards,

Michael
 
M

Miha Markic [MVP C#]

Back to the roots: Why do you need it?
I mean, there could be another approach to solve your problem.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Michael Maes said:
Hi Miha,

Thanks for your concern.

However: this thread isn't a solution to my issue because of two reasons:

° I (also) need the the instance-name in Design-Time
° DataSets aren't added to the 'components' IContainer - Collection.

I think I need another approach.....

Regards,

Michael


Miha Markic said:
Hi Michael,

Read this thread:
http://groups.google.com/groups?hl=...TF-8&q=get+name+of+component+group%3A*dotnet*
--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Hi,

I feel like a "novice" today.....
I'm creating my own (typed) DataSet-Classes and for one method I need the
DataSets Instance-Name (not Class-Name).
It seems like, however, that the (name)-"Property" of components isn't
accessible.

How do I retreive it's instance-name?

TIA,


Michael
 
M

Michael Maes

Basically: I am creating Custom DataSet-Classes (Typed) based on Schemes (of
course) and Extended with Properties, Methods, Events, ...

These DataSets can be 'Parents' or 'Children'. The Children are linked to
their Parents and can be (multiple instances) spread all over the
Application (currently in the same project). Children can synchronize their
parents and vice-versa, DataAdapters are 'centralized' and re-used, forms
are notified when DataSets are loading/loaded, .... Also general stuff is
'simplified' so that in coding you only have to type: DataSet.Fill,
DataSet.Update, DataSet.SaveToDisk(path), ...

I am only at the beginning of this 'journey' but got stumbled upon something
quite trivial as the instance-name for the method DataSet.SaveToDisk(path),
where path would be 'some_directory' + DataSetInstanceName + ".XML"

I know this is "silly", but my 'gut-feeling' tells me I'll need it somewhere
else in the verry near future too.

Regards,

Michael

Miha Markic said:
Back to the roots: Why do you need it?
I mean, there could be another approach to solve your problem.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Michael Maes said:
Hi Miha,

Thanks for your concern.

However: this thread isn't a solution to my issue because of two reasons:

° I (also) need the the instance-name in Design-Time
° DataSets aren't added to the 'components' IContainer - Collection.

I think I need another approach.....

Regards,

Michael
http://groups.google.com/groups?hl=...TF-8&q=get+name+of+component+group%3A*dotnet*
--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Hi,

I feel like a "novice" today.....
I'm creating my own (typed) DataSet-Classes and for one method I need the
DataSets Instance-Name (not Class-Name).
It seems like, however, that the (name)-"Property" of components isn't
accessible.

How do I retreive it's instance-name?

TIA,


Michael
 
K

Kevin Yu [MSFT]

Hi Michael,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to expose the reference to a
typed DataSet instance to other projects. If there is any misunderstanding,
please feel free to let me know.

As far as I know, we cannot get the instance-name in design time. If you
need to get the instance name in another assembly at runtime, please try to
use classes in System.Reflection namespace. Here is an example for getting
types and member information from an assembly. HTH.

public static void ReflectOnAssembly(Assembly assem) {
WriteLine(0, "Assembly: {0}", assem);
// Find Modules
foreach (Module m in assem.GetModules()) {
WriteLine(1, "Module: {0}", m);
// Find Types
foreach (Type t in m.GetTypes()) {
WriteLine(2, "Type: {0}", t);
// Find Members
foreach (MemberInfo mi in t.GetMembers())
WriteLine(3, "{0}: {1}", mi.MemberType, mi);
}
}
}
private static void WriteLine(Int32 indent, String format,
params Object[] args) {
Console.WriteLine(new String(¡® ¡¯, 3 * indent) + format, arg
s);
}

For more information, please check the following link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemReflection.asp

Does this answer your question? If anything is unclear, please feel free to
reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
M

Miha Markic [MVP C#]

Michael,

Can you use DataSetName property?
Other solution would be that you add a Name property that stores the
designer name at design time.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Michael Maes said:
Basically: I am creating Custom DataSet-Classes (Typed) based on Schemes (of
course) and Extended with Properties, Methods, Events, ...

These DataSets can be 'Parents' or 'Children'. The Children are linked to
their Parents and can be (multiple instances) spread all over the
Application (currently in the same project). Children can synchronize their
parents and vice-versa, DataAdapters are 'centralized' and re-used, forms
are notified when DataSets are loading/loaded, .... Also general stuff is
'simplified' so that in coding you only have to type: DataSet.Fill,
DataSet.Update, DataSet.SaveToDisk(path), ...

I am only at the beginning of this 'journey' but got stumbled upon something
quite trivial as the instance-name for the method DataSet.SaveToDisk(path),
where path would be 'some_directory' + DataSetInstanceName + ".XML"

I know this is "silly", but my 'gut-feeling' tells me I'll need it somewhere
else in the verry near future too.

Regards,

Michael

Miha Markic said:
Back to the roots: Why do you need it?
I mean, there could be another approach to solve your problem.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Michael Maes said:
Hi Miha,

Thanks for your concern.

However: this thread isn't a solution to my issue because of two reasons:

° I (also) need the the instance-name in Design-Time
° DataSets aren't added to the 'components' IContainer - Collection.

I think I need another approach.....

Regards,

Michael


"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Hi Michael,

Read this thread:
http://groups.google.com/groups?hl=...TF-8&q=get+name+of+component+group%3A*dotnet*
--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Hi,

I feel like a "novice" today.....
I'm creating my own (typed) DataSet-Classes and for one method I
need
the
DataSets Instance-Name (not Class-Name).
It seems like, however, that the (name)-"Property" of components isn't
accessible.

How do I retreive it's instance-name?

TIA,


Michael
 
M

Michael Maes

Hi Miha,

The latter is a solution (which I'm using currently) with only two Buts:

° I can't seem to find how to add the Designer-name dynamically at
design-time (basically: retreiving the Designer-name)
° The property must have a name other then 'Name' because otherwise it will
be reset to nothing (i think) every time VS serializes (so I called it
'InstanceName')

So do you have suggestion how to get the Designer-Name so I don't have to
Set the 'InstanceName' manually?

Thanks,

Michael



Miha Markic said:
Michael,

Can you use DataSetName property?
Other solution would be that you add a Name property that stores the
designer name at design time.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Michael Maes said:
Basically: I am creating Custom DataSet-Classes (Typed) based on Schemes (of
course) and Extended with Properties, Methods, Events, ...

These DataSets can be 'Parents' or 'Children'. The Children are linked to
their Parents and can be (multiple instances) spread all over the
Application (currently in the same project). Children can synchronize their
parents and vice-versa, DataAdapters are 'centralized' and re-used, forms
are notified when DataSets are loading/loaded, .... Also general stuff is
'simplified' so that in coding you only have to type: DataSet.Fill,
DataSet.Update, DataSet.SaveToDisk(path), ...

I am only at the beginning of this 'journey' but got stumbled upon something
quite trivial as the instance-name for the method DataSet.SaveToDisk(path),
where path would be 'some_directory' + DataSetInstanceName + ".XML"

I know this is "silly", but my 'gut-feeling' tells me I'll need it somewhere
else in the verry near future too.

Regards,

Michael

Miha Markic said:
Back to the roots: Why do you need it?
I mean, there could be another approach to solve your problem.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Hi Miha,

Thanks for your concern.

However: this thread isn't a solution to my issue because of two reasons:

° I (also) need the the instance-name in Design-Time
° DataSets aren't added to the 'components' IContainer - Collection.

I think I need another approach.....

Regards,

Michael


"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Hi Michael,

Read this thread:
http://groups.google.com/groups?hl=...TF-8&q=get+name+of+component+group%3A*dotnet*
--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Hi,

I feel like a "novice" today.....
I'm creating my own (typed) DataSet-Classes and for one method I need
the
DataSets Instance-Name (not Class-Name).
It seems like, however, that the (name)-"Property" of components isn't
accessible.

How do I retreive it's instance-name?

TIA,


Michael
 
M

Michael Maes

Hello (again) Kevin,

For the moment I need the Instance-name only in the same Assembly.
I'm not shure if I'm going to adapt these classes for usage in 'n-tier'
because reflection is (still) so slow.

I'm going to wait on that matter for vs 2005: Reflection has been (will be)
boosted and combined with Yukon I think the architecture of 'n-tier' will
slightly change (BusinessLogic on the SQL Server?)

So if you have any suggestions (meanwhile) how to retreive the Designer-Name
at design-time I would be verry glad.
I "believe" it must be possible since it's available to the
Property-Window....

Regards,

Michael
 
M

[MSFT]

Hi Michael,

When you call the method DataSet.SaveToDisk(path), did you want to save the
schema or actual data in the dataset? Based on my understand,
DataSet.SaveToDisk should be called at runtime, is this right?

Luke
Microsoft Online Support

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

Michael Maes

Hi Luke,

I think I know where you're aiming at but, yes, it's intended to save the
actual data of that instance (so it's runtime)....

Michael
 
K

Kevin Yu [MSFT]

Hi Michael,

Since the method is being called at runtime, the only way to access the
instance name is to use reflection classes, although they might be a bit
slower.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
M

Michael Maes

Hi Kevin,

I *could* access the instance-name in run-time but I *would like to* access
it in design-time.
It's ok for me to have a Property 'InstanceName' which is automatically
filled when I drag the component to the component-tray.
Isn't there any way to achieve this in design-time? (I hope so).

Thanks,

Michael
 
K

Kevin Yu [MSFT]

Hi Michael,

If you need to get the property name in design time, you have to
IReferenceService to achieve this. It's completely different from getting
reference in an assembly. Here I have written some sample code.

IReferenceService refsvc = this.GetService(typeof(IReferenceService)) as
IReferenceService;
string s = refsvc.GetName(this);
this.textBox1.Text = s;

The code snippet will get the (Name) property for a user control and
display it in a textbox. HTH.

For more information about IReferenceService, please check the following
link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemComponentModelDesignIReferenceServiceClassTopic.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
M

Michael Maes

Hi Kevin,

This is what I need. Thanks a lot.

I only can't figure out where to put the code, because in Sub New, the
DataSet isn't instanciated yet, so I get an "object reference ..."

Any idea's on this?
(I'm asking a lot ;-)))

Michael
 
K

Kevin Yu [MSFT]

You're welcome, Michael.

Where to put the code depends on how you are going to deal with the
DataSet. Generally, we can add the code to IComponentChangeService
interface's ComponentAdded and CoponentChanged event. For more information,
please check the following link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemComponentModelDesignIComponentChangeServiceClassTopic.asp

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
M

Michael Maes

Kevin,

You are an angel!
No really: Thanks a million times.

Everything put together is 110% of what I had in mind.

This kind if stuff is what makes it "all wurth" for me. I enjoy this alot (a
bit like brain-surgery I guess)

Once again: Thanks........

A very happy Michael,

Kindest regards
 
K

Kevin Yu [MSFT]

Hi Michael,

It was nice to hear that you have had the problem resolved and I'm glad
that I can provide you with useful information. Thanks for sharing your
experience with all the people here. If you have any questions, please feel
free to post them in the community.

Kevin Yu
=======
"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