Searching for an object in a component | | |
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 | | | | re: Searching for an object in a component
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" <emrenews-maillist@yahoo.com> wrote in message
news:ut4pQ9AeFHA.2500@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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
>[/color] | | | | re: Searching for an object in a component
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" <someone@nospam.com> wrote in message
news:uSXbYNBeFHA.3816@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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" <emrenews-maillist@yahoo.com> wrote in message
> news:ut4pQ9AeFHA.2500@TK2MSFTNGP10.phx.gbl...[color=green]
>> 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
>>[/color]
>
>[/color] | | | | re: Searching for an object in a component
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" <emrenews-maillist@yahoo.com> wrote in message
news:uhSPiLCeFHA.1044@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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" <someone@nospam.com> wrote in message
> news:uSXbYNBeFHA.3816@TK2MSFTNGP10.phx.gbl...[color=green]
>> 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" <emrenews-maillist@yahoo.com> wrote in message
>> news:ut4pQ9AeFHA.2500@TK2MSFTNGP10.phx.gbl...[color=darkred]
>>> 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
>>>[/color]
>>
>>[/color]
>
>[/color] | | | | re: Searching for an object in a component
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" <someone@nospam.com> wrote in message
news:ugq0YTCeFHA.2844@TK2MSFTNGP14.phx.gbl...[color=blue]
>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" <emrenews-maillist@yahoo.com> wrote in message
> news:uhSPiLCeFHA.1044@TK2MSFTNGP10.phx.gbl...[color=green]
>> 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" <someone@nospam.com> wrote in message
>> news:uSXbYNBeFHA.3816@TK2MSFTNGP10.phx.gbl...[color=darkred]
>>> 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" <emrenews-maillist@yahoo.com> wrote in message
>>> news:ut4pQ9AeFHA.2500@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
>>>>
>>>
>>>[/color]
>>
>>[/color]
>
>[/color] | | | | re: Searching for an object in a component
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" <emrenews-maillist@yahoo.com> wrote in message
news:u3qxCgCeFHA.3032@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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" <someone@nospam.com> wrote in message
> news:ugq0YTCeFHA.2844@TK2MSFTNGP14.phx.gbl...[color=green]
>>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" <emrenews-maillist@yahoo.com> wrote in message
>> news:uhSPiLCeFHA.1044@TK2MSFTNGP10.phx.gbl...[color=darkred]
>>> 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" <someone@nospam.com> wrote in message
>>> news:uSXbYNBeFHA.3816@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" <emrenews-maillist@yahoo.com> wrote in message
>>>> news:ut4pQ9AeFHA.2500@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
>>>>>
>>>>
>>>>
>>>
>>>[/color]
>>
>>[/color]
>
>[/color] | | | | re: Searching for an object in a component
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" <someone@nospam.com> wrote in message
news:OrkOLjCeFHA.1384@TK2MSFTNGP09.phx.gbl...[color=blue]
> 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" <emrenews-maillist@yahoo.com> wrote in message
> news:u3qxCgCeFHA.3032@TK2MSFTNGP10.phx.gbl...[color=green]
>> 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" <someone@nospam.com> wrote in message
>> news:ugq0YTCeFHA.2844@TK2MSFTNGP14.phx.gbl...[color=darkred]
>>>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" <emrenews-maillist@yahoo.com> wrote in message
>>> news:uhSPiLCeFHA.1044@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" <someone@nospam.com> wrote in message
>>>> news:uSXbYNBeFHA.3816@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" <emrenews-maillist@yahoo.com> wrote in message
>>>>> news:ut4pQ9AeFHA.2500@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
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>[/color]
>>
>>[/color]
>
>[/color] | | | | re: Searching for an object in a component
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" <emrenews-maillist@yahoo.com> wrote in message
news:ua6soyCeFHA.3184@TK2MSFTNGP15.phx.gbl...[color=blue]
>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" <someone@nospam.com> wrote in message
> news:OrkOLjCeFHA.1384@TK2MSFTNGP09.phx.gbl...[color=green]
>> 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" <emrenews-maillist@yahoo.com> wrote in message
>> news:u3qxCgCeFHA.3032@TK2MSFTNGP10.phx.gbl...[color=darkred]
>>> 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" <someone@nospam.com> wrote in message
>>> news:ugq0YTCeFHA.2844@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" <emrenews-maillist@yahoo.com> wrote in message
>>>> news:uhSPiLCeFHA.1044@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" <someone@nospam.com> wrote in message
>>>>> news:uSXbYNBeFHA.3816@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" <emrenews-maillist@yahoo.com> wrote in message
>>>>>> news:ut4pQ9AeFHA.2500@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
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>[/color]
>>
>>[/color]
>
>[/color] | | | | re: Searching for an object in a component
I am afraid it is too late for the change. But thanx for the advice. I will
consider it on my next project.
"Marina" <someone@nospam.com> wrote in message
news:OtYItCDeFHA.1456@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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" <emrenews-maillist@yahoo.com> wrote in message
> news:ua6soyCeFHA.3184@TK2MSFTNGP15.phx.gbl...[color=green]
>>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" <someone@nospam.com> wrote in message
>> news:OrkOLjCeFHA.1384@TK2MSFTNGP09.phx.gbl...[color=darkred]
>>> 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" <emrenews-maillist@yahoo.com> wrote in message
>>> news:u3qxCgCeFHA.3032@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" <someone@nospam.com> wrote in message
>>>> news:ugq0YTCeFHA.2844@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" <emrenews-maillist@yahoo.com> wrote in message
>>>>> news:uhSPiLCeFHA.1044@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" <someone@nospam.com> wrote in message
>>>>>> news:uSXbYNBeFHA.3816@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" <emrenews-maillist@yahoo.com> wrote in message
>>>>>>> news:ut4pQ9AeFHA.2500@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
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>[/color]
>>
>>[/color]
>
>[/color] |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,439 network members.
|