You can use the GetSchemaTable method on the DataReader to return this info.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqldatareaderclassgetschematabletopic.asp On 8/9/06, Fernando M. A. Gomes <[EMAIL PROTECTED]> wrote: > > > > Greetings all, > > I have a very simple question: > > I have a query like this: SELECT * FROM Table1 T1 RIGHT JOIN Table2 T2 > ON T1.id = T2.id > > I then execute a DataReader with this query. In the resulting DataReader > I can get the columnnames, types, etc. What I can't seem to get is the > tablename / alias the column belongs to. > > What I need > > I get something like: > > Column1, column2, column3 > > And I'd like to get something like: > > T1.column1, T1.column2, T2.column1, ... > > What I need is only the schema of the resulting "virtual table" and not > the actual values of each row. > > What I can do as a "work around" > > I can run the same query with "FOR XML AUTO, XMLSCHEMA, ELEMENTS XSINIL" > at the end. This gives me the complete schema of the resulting "virtual > table" and also a lot more info than I need. But what I get is well > organized and I can easily get the name of the table each resulting > column belongs to. > > Is there an easier way to do this? > > Any help will be more than welcome! Thanks! > > Best Regards, > > Fernando Gomes > > [Non-text portions of this message have been removed] > > > -- Dean Fiala Very Practical Software, Inc Now with Blogging... http://www.vpsw.com/blogbaby Microsoft MVP [Non-text portions of this message have been removed] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNet2/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

