在.NET中调用存储过程

来源:互联网 发布:ubuntu 学打字 编辑:程序博客网 时间:2024/05/01 02:29
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

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

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和SqlDataAdapterSqlconnection 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"]);}

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击