c. 商城导购服务部分相关代码
存储过程:
CREATE Procedure ProductSearch_Name
(
@ProductName char(30)
)
AS
SELECT
Products.ID as PID,name,productName,state,city,unitPrice
FROM
Products,Company
WHERE
productName LIKE
'%'+@ProductName+ '%'
and
Company.ID=Products.companyID
GO
相关类库:
public SqlDataReader ProductSearchByName(String ProductName)
{
// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ESMS"]);
SqlCommand myCommand = new SqlCommand("ProductSearch_Name", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Add Parameters to SPROC
SqlParameter parameterProductName = new SqlParameter("@ProductName", SqlDbType.Char, 30);
parameterProductName.Value = ProductName;
myCommand.Parameters.Add(parameterProductName);
// Execute the command
myConnection.Open();
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
// Return the datareader
return result;
}
一般搜索:
相关代码:
private void searchByName(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
String Name = Convert.ToString(Request.QueryString["Name"]);
productDB PDB =new productDB();
If(DropDownList.selectedValue = = “商品”)
{
SqlDataReader result=PDB.ProductSearchByName(Name);
//商品搜索
DataList1.DataSource =result;
DataList1.DataBind();
}
else
{
SqlDataReader result=PDB.CompanySearchByName(Name);
//商家搜索
DataList1.DataSource =result;
DataList1.DataBind();
}
}
//精确搜索搜索
<asp:HyperLink id="HyperLink1" runat="server" ForeColor="White" Font-Bold="True" Font-Size="X-Small"NavigateUrl="searchAdvance.aspx">高级搜索</asp:HyperLink>
精确搜索:
<< 上一页 [21] [22] [23] [24] [25] [26] [27] [28] [29] [30] ... 下一页 >>
ASP+SQL SERVER2000电子商城系统 第27页下载如图片无法显示或论文不完整,请联系qq752018766