`
lovexuwenhao
  • 浏览: 197161 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

asp.net调用SQL存储过程之回传多值

阅读更多

asp.net代码:

private   void   LoadData1()  
  {  
  string   Strconn=ConfigurationSettings.AppSettings["StrConn"].ToString();  
  SqlConnection   nwConn=new   SqlConnection(Strconn);  
  SqlCommand   SearchData=new   SqlCommand("ProductData1",nwConn);  
  SearchData.CommandType=CommandType.StoredProcedure;  
  SearchData.Parameters.Add("@ProductName1",SqlDbType.VarChar,50);  
  SearchData.Parameters["@ProductName1"].Direction=ParameterDirection.Output;  
  SearchData.Parameters.Add("@ProductType1",SqlDbType.VarChar,50);  
  SearchData.Parameters["@ProductType1"].Direction=ParameterDirection.Output;  
  SearchData.Parameters.Add("@ProductPrice1",SqlDbType.VarChar,50);  
  SearchData.Parameters["@ProductPrice1"].Direction=ParameterDirection.Output;  
  nwConn.Open();  
  SearchData.ExecuteNonQuery();  
  SearchData.Dispose();  
  nwConn.Close();  
  Product1_Name.Text=SearchData.Parameters["@ProductName1"].Value.ToString();  
  Product1_Type.Text=SearchData.Parameters["@ProductType1"].Value.ToString();  
  Product1_Price.Text=SearchData.Parameters["@ProductPrice1"].Value.ToString();  
  }  
 存储过程函数部分  
  CREATE   PROCEDURE   ProductData1    
  @ProductName1   varchar(50)   output,  
  @ProductType1   varchar(50)   output,  
  @ProductPrice1   varchar(50)   output  
    Begin  
  set   @ProductName1=(Select   Top   1   ProductName   From   Products1   order   by   CreateTime   DESC);  
  set   @ProductType1=(Select   Top   1   ProductType   From   Products1   order   by   CreateTime   DESC);  
  set   @ProductPrice1=(Select   Top   1   ProductPrice   From   Products1   order   by   CreateTime   DESC);  
    End

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics