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 ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[GetTablePro]
-- Add the parameters for the stored procedure here
AS
BEGIN
-- 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
摘自 愛因光的專欄