473,382 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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
Nov 19 '05 #1
8 1141
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class...
4
by: James | last post by:
We have a need to search through an entire drive for a specific file name. The process is currently written with recursive loops through each directory and the Scripting.FileSystemObject. Problem...
1
by: Darrel | last post by:
Can anyone recommend a product/technique/component that would be capable of indexing PDF and MSWord document's and then searching against them? I've used index serviices for things like this in...
3
by: Yavuz Bogazci | last post by:
hi, i am searching for a good diagram component. i need to view company related structural diagrams within .net WEBforms. are there recommended components? or perhaps tips and sources? ...
3
by: Pexi | last post by:
Hi, we have a component developed with VB6 (compiled as a single threaded dll), which we have used as Application level object for several years in classic asp without problems. Yet now, when we...
11
by: Andrus | last post by:
I'm implementing entity object which should populate its properties from database when property is first referenced. In RDL reports I use object properties like MyObject.MyProperty MyObject...
3
by: gary.bernstein | last post by:
I want to call a singleton getInstance function to retrieve a templatized object without knowing what types were used to create the singleton object in the first call to getInstance. How can I do...
3
by: Stephen Torri | last post by:
Here is my attempt at implementing a object factory. The purpose of this is to replace a large switch statement in a factory class with the functors. I get an error at line 88, marked, "expected...
7
by: colin | last post by:
Hi, Im a bit confused about when you cast a value type to an object. I have a property grid wich stores the data and the defualt as objects. the data is limited to primitive types, structs and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.