Monday, March 12, 2012

how to handle sql with selecting attributes from multiple tables

a sql like: "select t1.a, t2.b from t1, t2 ...",
how does ado.net handle the query result from this kind of sql?
thx.
hongyuyour question is unclear. but, for ado.net doesn't look any difference that
result is coming from one table or 10 tables as far as retrieveal is the
only aim.
say, it gives the same result as query analyzer/sql * plus gives, if you
write this query in that tools.
Rajesh Patel
"Jeff Lu" <hl_107@.yahoo.com> wrote in message
news:eA7LdphkDHA.2676@.TK2MSFTNGP11.phx.gbl...
> a sql like: "select t1.a, t2.b from t1, t2 ...",
> how does ado.net handle the query result from this kind of sql?
> thx.
> hongyu
>
One ResultSet, one DataTable
"Jeff Lu" <hl_107@.yahoo.com> wrote in message
news:eA7LdphkDHA.2676@.TK2MSFTNGP11.phx.gbl...
> a sql like: "select t1.a, t2.b from t1, t2 ...",
> how does ado.net handle the query result from this kind of sql?
> thx.
> hongyu
>
if i use DataReader to read the query results, how to get the meta data
of the columns from different tables?
thx.
Greg wrote:
> One ResultSet, one DataTable
>
> "Jeff Lu" <hl_107@.yahoo.com> wrote in message
> news:eA7LdphkDHA.2676@.TK2MSFTNGP11.phx.gbl...
>>a sql like: "select t1.a, t2.b from t1, t2 ...",
>>how does ado.net handle the query result from this kind of sql?
>>thx.
>>hongyu
>>
>
>
suppose there are 2 tables with 1-m relationship,
Order and Transaction(with orderId as the foreign key).
i want to get some Tx columns as well as some Order columns within
a single sql, which can be "select tx.attr1, tx.attr2, o.attr1 from
Transaction tx, Order o where tx.seq=? and tx.orderId=o.orderId".
with the query result from such a query, i can build a entity(let's
say a ReportingEntity) through some O-R mapping mechanism. The O-R
mapping layer needs meta data of the query result to build/bind
the entity. so, for each column/value of the DataReader, i
need to know its DB table name, DB column name and maybe its type.
DataReader.GetSchemaTable returns a DataTable, i didn't see a API
for getting the meta data across multiple tables mentioned above.
i guess i must have missed sth.
thx for your help.
William Ryan wrote:
> If you are using tables like that, you may want to consider using a
> DataRelation and pulling the tables individually, connecting them after
> you've grabbed them from the DB. If you are joining tables, you are pulling
> over redundant data that eats up bandwidth and depending on size, can really
> hinder performance. That's not to say that you should never join tables
> server side...but make sure that's really the way you want to do it. From
> your later post, you mention the meta data. I'm not sure what platform you
> are referring to, or what specific meta data you are referring to, but
> DataReader.GetSchemaTable will give you basic information about the fields
> pulled over.
> What specifically in the MD are you looking for? Let me know and I can
> probably be of more help.
> Bill
> "Jeff Lu" <hl_107@.yahoo.com> wrote in message
> news:eA7LdphkDHA.2676@.TK2MSFTNGP11.phx.gbl...
>>a sql like: "select t1.a, t2.b from t1, t2 ...",
>>how does ado.net handle the query result from this kind of sql?
>>thx.
>>hongyu
>>
>
>

Labels: , , , , , , , , , ,

How to handle multiple UserControls that manipulate the same underlying data?

How should I handle the sitaution where two or more UserControls on the same page are using ObjectDataSources that leverage the same business object?

For example, UserControlA and UserControlB are both using BusinessObjectA via their respective ObjectDataSource. However, there does not appear to be a guarentee that UserControlA's events (i.e., DELETing data) fire before UserControlB's events (i.e., SELECTing data.) The result is that UserControlB can (and does) display incorrect data for the page, as it performed its SELECT before UserControlA performed its DELETE.

The situation that I find myself in at the moment is a page made up of GenericWebParts via dragging these UserControls into a WebPartZone. The controls are designed to be independant of one another, hence the reason why they each have their own ObjectDataSource. The problem is arising just as described above ... when I delete data via one UserControl, another UserControl on the page that makes decisions based upon the same data does not see the changes until a forced page refresh.

I did a little digging into this tonight and sure enough, UserControlB is being loaded before the events for UserControlA are firing, resulting in UserControlB read data before UserControlA has a chance to delete it.

I'm able to hack the solution by performing the delete opeartion from another page. So instead of enabling deletes via UserControlA's GridView, I've added a Hyperlink Field to ControlA's GridView which calls a Delete.aspx and then redirects back to the default page. However, this does not feel very clean at all.

Labels: , , , , , , , , , , ,