How to: Can you build a Typed DataSet for a stored procedure w/o using a DataAdapter?

E

Eric

If you want to create a DataSet, you can drag tables from Server explorer
into it, but not stored procedures. Is there any other way than using a
DataAdapter and calling Generate DataSet to get a typed dataSet that uses
sprocs instead of tables?

p.s. Does anyone know if in VS 2005 you will be able to drag and drop sprocs
onto a DataSet object?
 
D

David Browne

Eric said:
If you want to create a DataSet, you can drag tables from Server explorer
into it, but not stored procedures. Is there any other way than using a
DataAdapter and calling Generate DataSet to get a typed dataSet that uses
sprocs instead of tables?

Yes. It may seem terribly obvious, but use the DataSet designer and just do
it by hand.

If you don't want to do that, write a view which returns the same row type
and drag that into the DataSet designer. I always write views to "publish"
the row type returned by functions and stored procedures.
p.s. Does anyone know if in VS 2005 you will be able to drag and drop
sprocs
onto a DataSet object?

The problem is that it's difficult to get SqlServer to return table metadata
information from a stored procedure. It tries to run the proc with SET
FMTONLY ON, but it's complicated and unreliable.

David
 
M

Mythran

Eric said:
If you want to create a DataSet, you can drag tables from Server explorer
into it, but not stored procedures. Is there any other way than using a
DataAdapter and calling Generate DataSet to get a typed dataSet that uses
sprocs instead of tables?

p.s. Does anyone know if in VS 2005 you will be able to drag and drop
sprocs
onto a DataSet object?

What?!? I can drag-n-drop sprocs from SQL Server 2000 onto a DataSet just
fine, and it creates the typed dataset with the results the stored procedure
returns along with their data types just as if it were a table. I'm using
VS 2003...what are you using?

Mythran
 
E

Eric

--- Stuff deleted for Brevity
The problem is that it's difficult to get SqlServer to return table metadata
information from a stored procedure. It tries to run the proc with SET
FMTONLY ON, but it's complicated and unreliable.

Tell me about it. In Crystal Reports, when you attempt to set the
DataSource.Location Property of a report in code, if it's a sproc, it
actually executes the sproc in question whereas if it's a table it makes
some quick system calls to get metadata. I dont even think SET FMTONLY ON
was used. For a report against a giant database that was.....problematic,
especially if there were multiple tables in the report.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top