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

Searching for an object in a component

P: n/a
Hi,

I have a class named MyDataAdapter that derives from
System.ComponentModel.Component and it contains all of my SqlDataAdapter
objects(around a 100).

How can I find a SqlDataAdapter in the MyDataAdapter instance at run-time by
its name.

e-mre
Nov 19 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Have MyDataAdapter add all the adapters to a private hashtable by name. So
something like:

myHashTable.Add("adapter1",adapter1)
....

Then right a method to just retrieve the right adapter out of the hashtable
by name.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:ut**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a class named MyDataAdapter that derives from
System.ComponentModel.Component and it contains all of my SqlDataAdapter
objects(around a 100).

How can I find a SqlDataAdapter in the MyDataAdapter instance at run-time
by its name.

e-mre

Nov 19 '05 #2

P: n/a
Sounds like a solution but there must a better way. I mean I was expecting
to see something like
component.Findcontrol("aaa")
But I couldn't find anything like this.

e-mre

"Marina" <so*****@nospam.com> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
Have MyDataAdapter add all the adapters to a private hashtable by name. So
something like:

myHashTable.Add("adapter1",adapter1)
...

Then right a method to just retrieve the right adapter out of the
hashtable by name.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:ut**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a class named MyDataAdapter that derives from
System.ComponentModel.Component and it contains all of my SqlDataAdapter
objects(around a 100).

How can I find a SqlDataAdapter in the MyDataAdapter instance at run-time
by its name.

e-mre


Nov 19 '05 #3

P: n/a
I don't think that's going to happen for components. This is compiled code,
it just doesn't work like that - the way interpreted javascript does.

By the way, if it did work that way, it would be pretty slow, because it
would have to involve reflection. You can write it that way using
reflection, but it's going to be a ton more code then the method I
suggested, and much slower.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:uh**************@TK2MSFTNGP10.phx.gbl...
Sounds like a solution but there must a better way. I mean I was expecting
to see something like
component.Findcontrol("aaa")
But I couldn't find anything like this.

e-mre

"Marina" <so*****@nospam.com> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
Have MyDataAdapter add all the adapters to a private hashtable by name.
So something like:

myHashTable.Add("adapter1",adapter1)
...

Then right a method to just retrieve the right adapter out of the
hashtable by name.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:ut**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a class named MyDataAdapter that derives from
System.ComponentModel.Component and it contains all of my SqlDataAdapter
objects(around a 100).

How can I find a SqlDataAdapter in the MyDataAdapter instance at
run-time by its name.

e-mre



Nov 19 '05 #4

P: n/a
While thinking I came to realize that MyDataAdapter does not have to be a
component. I am not using anything specific to component class.
It can be a control or something else .. I don't know.

Can this lead me to another solution.?

e-mre

"Marina" <so*****@nospam.com> wrote in message
news:ug**************@TK2MSFTNGP14.phx.gbl...
I don't think that's going to happen for components. This is compiled
code, it just doesn't work like that - the way interpreted javascript does.

By the way, if it did work that way, it would be pretty slow, because it
would have to involve reflection. You can write it that way using
reflection, but it's going to be a ton more code then the method I
suggested, and much slower.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:uh**************@TK2MSFTNGP10.phx.gbl...
Sounds like a solution but there must a better way. I mean I was
expecting to see something like
component.Findcontrol("aaa")
But I couldn't find anything like this.

e-mre

"Marina" <so*****@nospam.com> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
Have MyDataAdapter add all the adapters to a private hashtable by name.
So something like:

myHashTable.Add("adapter1",adapter1)
...

Then right a method to just retrieve the right adapter out of the
hashtable by name.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:ut**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a class named MyDataAdapter that derives from
System.ComponentModel.Component and it contains all of my
SqlDataAdapter objects(around a 100).

How can I find a SqlDataAdapter in the MyDataAdapter instance at
run-time by its name.

e-mre



Nov 19 '05 #5

P: n/a
No. I just explained why.

The FindControl is only something in asp.net, because when the .aspx or
..ascx is parsed, asp.net can pick up those controls by name.

You just can't do that for arbitrary variables.

I didn't ask before, but is it really necessary to create 100 data adapters
all at once? There have to be better ways to accomplish what you want.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
While thinking I came to realize that MyDataAdapter does not have to be a
component. I am not using anything specific to component class.
It can be a control or something else .. I don't know.

Can this lead me to another solution.?

e-mre

"Marina" <so*****@nospam.com> wrote in message
news:ug**************@TK2MSFTNGP14.phx.gbl...
I don't think that's going to happen for components. This is compiled
code, it just doesn't work like that - the way interpreted javascript
does.

By the way, if it did work that way, it would be pretty slow, because it
would have to involve reflection. You can write it that way using
reflection, but it's going to be a ton more code then the method I
suggested, and much slower.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:uh**************@TK2MSFTNGP10.phx.gbl...
Sounds like a solution but there must a better way. I mean I was
expecting to see something like
component.Findcontrol("aaa")
But I couldn't find anything like this.

e-mre

"Marina" <so*****@nospam.com> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
Have MyDataAdapter add all the adapters to a private hashtable by name.
So something like:

myHashTable.Add("adapter1",adapter1)
...

Then right a method to just retrieve the right adapter out of the
hashtable by name.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:ut**************@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> I have a class named MyDataAdapter that derives from
> System.ComponentModel.Component and it contains all of my
> SqlDataAdapter objects(around a 100).
>
> How can I find a SqlDataAdapter in the MyDataAdapter instance at
> run-time by its name.
>
> e-mre
>



Nov 19 '05 #6

P: n/a
I am afraid yes. Each DataAdapter is used for operating on a table and I
have a huge database.I prepare all the DataAdapters at design-time and
generate DataSet tables for them also at design time.

Now I am trying to do the HashTable solution you've proposed earlier. I
guess it will do the job.
"Marina" <so*****@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
No. I just explained why.

The FindControl is only something in asp.net, because when the .aspx or
.ascx is parsed, asp.net can pick up those controls by name.

You just can't do that for arbitrary variables.

I didn't ask before, but is it really necessary to create 100 data
adapters all at once? There have to be better ways to accomplish what you
want.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
While thinking I came to realize that MyDataAdapter does not have to be a
component. I am not using anything specific to component class.
It can be a control or something else .. I don't know.

Can this lead me to another solution.?

e-mre

"Marina" <so*****@nospam.com> wrote in message
news:ug**************@TK2MSFTNGP14.phx.gbl...
I don't think that's going to happen for components. This is compiled
code, it just doesn't work like that - the way interpreted javascript
does.

By the way, if it did work that way, it would be pretty slow, because it
would have to involve reflection. You can write it that way using
reflection, but it's going to be a ton more code then the method I
suggested, and much slower.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:uh**************@TK2MSFTNGP10.phx.gbl...
Sounds like a solution but there must a better way. I mean I was
expecting to see something like
component.Findcontrol("aaa")
But I couldn't find anything like this.

e-mre

"Marina" <so*****@nospam.com> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
> Have MyDataAdapter add all the adapters to a private hashtable by
> name. So something like:
>
> myHashTable.Add("adapter1",adapter1)
> ...
>
> Then right a method to just retrieve the right adapter out of the
> hashtable by name.
>
> "YunusEmre" <em***************@yahoo.com> wrote in message
> news:ut**************@TK2MSFTNGP10.phx.gbl...
>> Hi,
>>
>> I have a class named MyDataAdapter that derives from
>> System.ComponentModel.Component and it contains all of my
>> SqlDataAdapter objects(around a 100).
>>
>> How can I find a SqlDataAdapter in the MyDataAdapter instance at
>> run-time by its name.
>>
>> e-mre
>>
>
>



Nov 19 '05 #7

P: n/a
In my opinion this is very poor design. You should be writing your own data
access code, in a generic enough manner, that you can update any table you
need to by calling a few methods.

You should not be using the design time wizard to generate 100 objects. My
opinion is that the wizard is a good learning tool and a way to get started,
but should not be used to design real applications.

I would recommend throwing it all away, and writing all the code yourself.
Once you write the update logic once, you should be able to update any set
of data that you have, if you have written it generically. In your current
model, you need to keep all the adapters in sync, and do all this work when
you add new ones.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:ua**************@TK2MSFTNGP15.phx.gbl...
I am afraid yes. Each DataAdapter is used for operating on a table and I
have a huge database.I prepare all the DataAdapters at design-time and
generate DataSet tables for them also at design time.

Now I am trying to do the HashTable solution you've proposed earlier. I
guess it will do the job.
"Marina" <so*****@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
No. I just explained why.

The FindControl is only something in asp.net, because when the .aspx or
.ascx is parsed, asp.net can pick up those controls by name.

You just can't do that for arbitrary variables.

I didn't ask before, but is it really necessary to create 100 data
adapters all at once? There have to be better ways to accomplish what you
want.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
While thinking I came to realize that MyDataAdapter does not have to be
a component. I am not using anything specific to component class.
It can be a control or something else .. I don't know.

Can this lead me to another solution.?

e-mre

"Marina" <so*****@nospam.com> wrote in message
news:ug**************@TK2MSFTNGP14.phx.gbl...
I don't think that's going to happen for components. This is compiled
code, it just doesn't work like that - the way interpreted javascript
does.

By the way, if it did work that way, it would be pretty slow, because
it would have to involve reflection. You can write it that way using
reflection, but it's going to be a ton more code then the method I
suggested, and much slower.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:uh**************@TK2MSFTNGP10.phx.gbl...
> Sounds like a solution but there must a better way. I mean I was
> expecting to see something like
> component.Findcontrol("aaa")
> But I couldn't find anything like this.
>
> e-mre
>
> "Marina" <so*****@nospam.com> wrote in message
> news:uS**************@TK2MSFTNGP10.phx.gbl...
>> Have MyDataAdapter add all the adapters to a private hashtable by
>> name. So something like:
>>
>> myHashTable.Add("adapter1",adapter1)
>> ...
>>
>> Then right a method to just retrieve the right adapter out of the
>> hashtable by name.
>>
>> "YunusEmre" <em***************@yahoo.com> wrote in message
>> news:ut**************@TK2MSFTNGP10.phx.gbl...
>>> Hi,
>>>
>>> I have a class named MyDataAdapter that derives from
>>> System.ComponentModel.Component and it contains all of my
>>> SqlDataAdapter objects(around a 100).
>>>
>>> How can I find a SqlDataAdapter in the MyDataAdapter instance at
>>> run-time by its name.
>>>
>>> e-mre
>>>
>>
>>
>
>



Nov 19 '05 #8

P: n/a
I am afraid it is too late for the change. But thanx for the advice. I will
consider it on my next project.
"Marina" <so*****@nospam.com> wrote in message
news:Ot**************@TK2MSFTNGP10.phx.gbl...
In my opinion this is very poor design. You should be writing your own
data access code, in a generic enough manner, that you can update any
table you need to by calling a few methods.

You should not be using the design time wizard to generate 100 objects. My
opinion is that the wizard is a good learning tool and a way to get
started, but should not be used to design real applications.

I would recommend throwing it all away, and writing all the code yourself.
Once you write the update logic once, you should be able to update any set
of data that you have, if you have written it generically. In your current
model, you need to keep all the adapters in sync, and do all this work
when you add new ones.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:ua**************@TK2MSFTNGP15.phx.gbl...
I am afraid yes. Each DataAdapter is used for operating on a table and I
have a huge database.I prepare all the DataAdapters at design-time and
generate DataSet tables for them also at design time.

Now I am trying to do the HashTable solution you've proposed earlier. I
guess it will do the job.
"Marina" <so*****@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
No. I just explained why.

The FindControl is only something in asp.net, because when the .aspx or
.ascx is parsed, asp.net can pick up those controls by name.

You just can't do that for arbitrary variables.

I didn't ask before, but is it really necessary to create 100 data
adapters all at once? There have to be better ways to accomplish what
you want.

"YunusEmre" <em***************@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
While thinking I came to realize that MyDataAdapter does not have to be
a component. I am not using anything specific to component class.
It can be a control or something else .. I don't know.

Can this lead me to another solution.?

e-mre

"Marina" <so*****@nospam.com> wrote in message
news:ug**************@TK2MSFTNGP14.phx.gbl...
>I don't think that's going to happen for components. This is compiled
>code, it just doesn't work like that - the way interpreted javascript
>does.
>
> By the way, if it did work that way, it would be pretty slow, because
> it would have to involve reflection. You can write it that way using
> reflection, but it's going to be a ton more code then the method I
> suggested, and much slower.
>
> "YunusEmre" <em***************@yahoo.com> wrote in message
> news:uh**************@TK2MSFTNGP10.phx.gbl...
>> Sounds like a solution but there must a better way. I mean I was
>> expecting to see something like
>> component.Findcontrol("aaa")
>> But I couldn't find anything like this.
>>
>> e-mre
>>
>> "Marina" <so*****@nospam.com> wrote in message
>> news:uS**************@TK2MSFTNGP10.phx.gbl...
>>> Have MyDataAdapter add all the adapters to a private hashtable by
>>> name. So something like:
>>>
>>> myHashTable.Add("adapter1",adapter1)
>>> ...
>>>
>>> Then right a method to just retrieve the right adapter out of the
>>> hashtable by name.
>>>
>>> "YunusEmre" <em***************@yahoo.com> wrote in message
>>> news:ut**************@TK2MSFTNGP10.phx.gbl...
>>>> Hi,
>>>>
>>>> I have a class named MyDataAdapter that derives from
>>>> System.ComponentModel.Component and it contains all of my
>>>> SqlDataAdapter objects(around a 100).
>>>>
>>>> How can I find a SqlDataAdapter in the MyDataAdapter instance at
>>>> run-time by its name.
>>>>
>>>> e-mre
>>>>
>>>
>>>
>>
>>
>
>



Nov 19 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.