How can I get a schema the record set that is returned from a stored procedure?

Hi

A few days back one of my collegue was asking me on how does the dataset gets the schema of the Table even when we are using the Stored procedure. He wanted to get the schema himself and work around that.

The data reader includes a getSchemaTable method which gets the schema in a data table on the result set. each row in the returned data table corresponds to a Column in the actual resutset. This schema can be utilized to infer the Column Name, its data type etc. To get additional schema information like base table name, column name etc. with commandBehaviour.keyinfo.

There are a few problems with this. If the stored procedure returns different result set depending on the input parameter, this might not work. Also if the stored procedure is using a Temporary table you might not get the addition schema with the CommandBehavior.KeyInfo.

Hope this helps
Thanks
Vikram


Share this post   Email it |  digg it! |  reddit! |  bookmark it!

Feedback

Please post your comments:

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box:
 
Copyright © 2006 - 2009 Vikram Lakhotia