📄 default.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using System.Data.SqlClient;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|db_schoolcomputer.mdb;");
con.Open();
string strSql = "select 商品名称 from tb_08";
OleDbDataAdapter myAdapter = new OleDbDataAdapter(strSql, con);
DataSet ds = new DataSet();
myAdapter.Fill(ds, "tb_08");
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "商品名称";
DropDownList1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|db_schoolcomputer.mdb;");
con.Open();
string strSql = "select * from tb_08 where 商品名称='"+DropDownList1.SelectedValue.ToString()+"'";
OleDbDataAdapter myAdapter = new OleDbDataAdapter(strSql, con);
DataSet ds = new DataSet();
myAdapter.Fill(ds, "tb_08");
ReportDocument studentsReport = new ReportDocument();//定义ReportDocument类对象
studentsReport.Load(Server.MapPath("CrystalReport.rpt"));//加载报表
studentsReport.SetDataSource(ds);//加载数据源
this.CrystalReportViewer1.ReportSource = studentsReport;//为CrystalReportViewer控件指定报表
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -