水晶报表提示要输入用户名密码?我用的是access数据库
代码:
public void dbSelect()
{
//string strSql = "SELECT cxpx.ID, cxpx.sname, cxpx.sex, cxpx.age, cxpx.address, cxpx.idcard, cxpx.tel, format(cxpx.pxdate,'yyyy-mm-dd') as pxdate,cxpx.pxtime , pxadd.name FROM (cxpx RIGHT OUTER JOIN pxadd ON cxpx.pxadd = pxadd.code)";
string strSql = "SELECT sname,sex,idcard,age,address,pxllcj,pxsccj,pxkno,pxhgzno FROM cxpx";
if (ViewState["start"].ToString() != "" && ViewState["end"].ToString() != "")
{
strSql += " where cxpx.pxdate between #" + ViewState["start"].ToString() + "# and #" + ViewState["end"].ToString() + "#";
}
OleDbConnection conn = new OleDbConnection(connString);
try
{
conn.Open();
DataSet ds = new DataSet();
OleDbCommand comm = new OleDbCommand(strSql,conn);
OleDbDataAdapter adp = new OleDbDataAdapter(comm);
adp.Fill(ds,"cxpx");
CrystalReportSource.ReportDocument.Load(Server.MapPath("cxpxCountPrintReport.rpt"));
Show(this, Server.MapPath("cxpxCountPrintReport.rpt"));
CrystalReportSource.ReportDocument.SetDataSource(ds.Tables["cxpx"]);
CrystalReportSource.DataBind();
CrystalReportViewer1.ReportSource = CrystalReportSource;
CrystalReportViewer1.DataBind();
}
catch(Exception ex)
{
Show(this,ex.ToString());
}
finally
{
conn.Close();
}
}