C # Return the table set through the Stored Procedure

Source: Internet
Author: User

 

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

From the column of AI yingguang

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.