2017-01-22 13 views
0
public void Reports(string query, CrystalReportViewer crystalReportViewer1, string tblname, string rptname) 
{ 
    con.Close(); 

    try { 

     ReportDocument Report = new ReportDocument(); 
     con.Open(); 
     SqlDataAdapter da = new SqlDataAdapter(query, con); 
     DataSet ds = new DataSet(); 
     //ds.Tables.Add("Customer_Transaction_Master"); 
     da.Fill(ds, tblname); 
     // Report.Load(System.Windows.Forms.Application.StartupPath + "\\Reports" + rptname); 
     Report.Load(Application.StartupPath + "\\Reports" + rptname); 
     Report.SetDataSource(ds.Tables[tblname]); 
     Report.Refresh(); 
     crystalReportViewer1.ReportSource = Report; 
     crystalReportViewer1.RefreshReport();      
     Report.PrintOptions.PaperOrientation = PaperOrientation.Portrait; 
     Report.PrintOptions.PaperSize = PaperSize.PaperA4; 
     Report.PrintToPrinter(1, false, 0, 15); 
     Report.Close(); 
    } 
    catch(Exception ex) 
    { 
     MessageBox.Show(ex.Message); 
     //throw ex; 

    } 
    finally 
    { 
     con.Close(); 
    } 
} 

*********** ---------ボタンクリック--------- ***** *レポートの読み込みに失敗しました...水晶レポートエラー

try 
{ 
    frmdailyreport frdp = new frmdailyreport(); 
    gd.Reports("select * from tbl_bill where date='" + dailydate.Text + "' ", frdp.dailycrystal, "tbl_bill", "//daily.rpt"); 
    frdp.Show(); 
} 
catch (Exception ex) 
{ 
    MessageBox.Show(ex.Source); 
    MessageBox.Show(ex.Message); 
} 
  • 私はパス
  • にも与えられた権限を確認する]
  • 一時フォルダが完全なユーザーコントロールのアクセス許可

を持っているが、それでもRを読み込みますeportが失敗しました... 問題は、ボタンをクリックすると "Load Report Failed error"と表示され、 "Ok"をクリックするとレポートが表示されません。

globe.csは私のクラスファイルであり、このクラスファイルのオブジェクトは "gd"です。

ありがとうございます。

答えて

0

ロードレポートエラーは、パスが間違っていることを意味するレポートがレポート内の正確なパスになることを意味します。すなわち、Report.Load("C:\\Program Files\Reports\dailyReport.rpt");がロードされると、Applicationを使用して間違ったパスを与えていることを意味します。パスを確認して、レポートの読み込みコードをボタン内に配置します。問題が解決されたかどうかは、ここでテストおよびコメントするためにクリックしてください。

+0

[解決済み]パスエラーとプライマリ出力の問題 – MAYUR

+0

私の答えがあなたの問題をトレースするのに役立ったら、答えとして選択してください。 –

関連する問題