Call a SQL Server stored procedure without parameters with ADO.NET

xiaoxiao2021-03-06  36

Inside SQL Server, build a stored procedure in your catalog.

Create Procedure [DBO]. [Userprocedure] AS

SELECT * from [user]

Go

Call in ADO.NET

Private Void Page_Load (Object Sender, System.EventArgs E)

{

SqlConnection Con = New SqlConnection ();

Con.Connectionstring = "Workstation ID = overmind; packet size = 4096; user ID = sa; password = sa; data source = overmind; persist security info = false; initial catalog = wztj;

C.Open ();

Sqlcommand cm = new SQLCOMMAND ("UserProcedure", CON;

DataSet DS = New Dataset ();

SqlDataAdapter ad = New SqlDataAdapter (cm);

Ad.fill (DS, "User");

DataGrid1.datasource = DS;

DataGrid1.databind ();

// put user code to initialize the page

}

:) is so simple

转载请注明原文地址:https://www.9cbs.com/read-57985.html

New Post(0)