日期:2014-05-20  浏览次数:20824 次

阿泰大哥帮我看看-发布到服务器的水晶报表打印为什么访问到不局域网里的共享打印机
C# code


    /// <summary>
    /// 打印机列表
    /// </summary>
    /// <returns></returns>
    private ArrayList GetPrinter()
    {
        ArrayList array = new ArrayList();
        foreach (string iprt in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
            array.Add(iprt);
        return array;
    }




打印部分
C# code

   ReportDocument doc = new ReportDocument();
   doc.PrintOptions.PrinterName = ddl_printList.SelectedValue.ToString();
   CrytalName = "../PrintManager/Connection.rpt";
   doc.Load(Server.MapPath("" + CrytalName + ""));
   doc.SetDataSource(dsDataSet);
    doc.PrintToPrinter(1, false, 0, 0);



打印机是装在局域网的共享打印机
服务器上添加了此台打印机


目前在本地和服务器用VS2008环境测试是可以打印的。但是发布之后用
就会提示

 System.Drawing.Printing.InvalidPrinterException: 对访问打印机“\\192.168.16.99\HP LaserJet 3050 Series PCL 6”的设置无效。

请高手帮我看看,到底如何解决~~

最后贴下最后的打印代码(实现选择性打印的多张水晶报表)
C# code
 
/// <summary>
    /// 打印
    /// </summary>
    /// <param name="sender"> </param>
    /// <param name="e"> </param>
    protected void btnSurePrint_Click(object sender, EventArgs e)
    {
        string id = Request.QueryString["id"];//结论书id
        string printId = string.Empty;
        for (int i = 0; i < this.cblPrint.Items.Count; i++)
        {
            if (this.cblPrint.Items[i].Selected)
            {
                printId += this.cblPrint.Items[i].Value+",";
            }
        }
        printId += printId.Substring(0, printId.LastIndexOf(','));//需要打印的id

        #region  选择性打印

        DB_Conclusion dsDataSet = new DB_Conclusion();
        string con = ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString;
       
        using (SqlConnection objSqlConnection = new SqlConnection(con))
        {
           
     
        //结论书
        string sql = "SELECT a.cId, a.cTotalNo, a.cTitle, a.cContent, a.cAddPeople, a.cDate, b.oName FROM Conclusion AS a INNER JOIN  Office AS b ON a.cIdentificationUnit = b.oid and a.cid=" + id;
        SqlDataAdapter sdaAdapter = new SqlDataAdapter(sql, objSqlConnection);
        sdaAdapter.Fill(dsDataSet, "Conclusion");
        sdaAdapter.Dispose();
        //sdaAdapter.

     


        //现场勘查表
        string sql2 = "SELECT sId, sCid, sPeople, sDate, sPlace, sObject, sAcompany, sRemark, sIsregout FROM Scene where sCid=" + id;
        SqlDataAdapter sdaAdapter2 = new SqlDataAdapter(sql2, objSqlConnection);
        sdaAdapter2.Fill(dsDataSet, "Scene");
        sdaAdapter2.Dispose();