c# 通过存储过程返回表集合

来源:互联网 发布:沙发推荐 知乎 编辑:程序博客网 时间:2024/06/05 17:43
 
 DataSet ds = new DataSet();            SqlConnection conn = new SqlConnection(Properties.Settings.Default.MyDataBaseConnectionString);            conn.Open();            SqlCommand cmd = new SqlCommand("GetTablePro",conn);            cmd.CommandType = CommandType.StoredProcedure;            SqlDataAdapter adapter = new SqlDataAdapter(cmd);            adapter.Fill(ds);            if(ds.Tables.Count > 1)            dataGridView1.DataSource = ds.Tables[1];

set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgo-- =============================================-- Author:<Author,,Name>-- Create date: <Create Date,,>-- Description:<Description,,>-- =============================================ALTER PROCEDURE [dbo].[GetTablePro]-- Add the parameters for the stored procedure hereASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SET NOCOUNT ON;    -- Insert statements for procedure here    select * from employee;    SELECT * from class;END