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