繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> .NET Framework >> 在.NET中调用存储过程

在.NET中调用存储过程

2004-10-01 08:26:10  作者:  来源:互联网  浏览次数:32  文字大小:【】【】【
简介:今天试了一下用存储过程取得数据。归纳方法如下: 1.用SqlCommand和DataSet: SqlConnection conn=new SqlConnection("server=(local);uid=;password=;database="); SqlCommand cmd=new SqlCommand(&q...
关键字:.NET 存储 过程

今天试了一下用存储过程取得数据。归纳方法如下:

1.用SqlCommand和DataSet:

SqlConnection conn=new SqlConnection("server=(local);uid=;password=;database=");

SqlCommand cmd=new SqlCommand("StoreProcedure",connn);

cmd.CommandType=CommandType.StoreProcedure;

SqlDataAdapter dsCommand=new SqlDataAdapter(cmd);

DataSet ds=new DataSet();

dsCommand.Fill(ds);

2.用SqlCommand和SqlDataAdapter

Sqlconnection conn=new SqlConnection("server=(local);uid=;password=;database=");

SqlCommand cmd=new SqlCommand("StoreProcedure",conn);

cmd.CommandType=CommandType.StoreProcedure;

SqlDataReader dr=cmd.ExecuteReader()

while(dr.Read())

{

Response.Write(dr.Item["Field"]);

}

责任编辑:admin
相关文章