存储储过程:
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
Create PROCEDURE dbo.Test
@MaxId int --最大ID
AS
Select * From Union_User Where id<=@MaxId
GO
C#程序:
![程序代码](images/code.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SolutionSQLServer"].ToString());
SqlCommand cmd = new SqlCommand("Test",conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@MaxId", SqlDbType.Int).Value = 12000;
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
GridView1.DataSource = dt.DefaultView;
GridView1.DataBind();