How to generate a dataset from stored procedure which have many resultsets?

  • Thread starter Thread starter abc my vclass
  • Start date Start date
A

abc my vclass

How to generate a dataset from stored procedure which have many resultsets?

I try Dataset designer from VS2005, it only generate first table from stored
procedure on server explorer. Another table cannot to generate. How should
I do?
 
If you use following code (and in your STORE_PROCEDURE there are
multi-queries), you can fill dataset with multi-tables.

DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection(CONNECTION_STRING);
SqlDataAdapter dap = new SqlDataAdapter();
SqlCommand command = conn.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "STORE_PROCEDURE_NAME";

// add parameters if any

dap.SelectCommand = command;
dap.Fill(ds);

HTH

Elton Wang
 
Back
Top