See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
CrystalDecisions.Shared.CrystalReportsException: Load report failed. ---> System.Runtime.InteropServices.COMException (0x80004005): The system cannot find the file specified.
at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
--- End of inner exception stack trace ---
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)
at student.PrintForm.btnPrint_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Tag : .NET, MySQL, Crystal Report, Win (Windows App), C#, VS 2008 (.NET 3.x)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using MySql.Data.MySqlClient;
using System.Diagnostics;
using CrystalDecisions.CrystalReports.Engine;
using Microsoft.VisualBasic;
namespace student
{
public partial class UserReport : Form
{
ClassConnectDB Connect = new ClassConnectDB();
public UserReport()
{
InitializeComponent();
}
private void btnReport_Click(object sender, EventArgs e)
{
Connect.ConnectDB();//ติดต่ฐานข้อมูล
String strSQL;
DataTable dt = null;
strSQL = "SELECT user_id,user_name,user_address,user_province";
strSQL += ",user_zipcode,user_mail,user_phone FROM user where user_id like '%" + txtId.Text + "%' ";
MySqlDataAdapter adapter;
MySqlCommand objCmd;
objCmd = new MySqlCommand(strSQL, Connect.objConn);//ประมวลผล
adapter = new MySqlDataAdapter(objCmd);//เก็บข้อมูลไว้ที่ data adapter
DataSet data = new DataSet();//สร้าง data set
adapter.Fill(data, "user");//เก็บข้อมูลไว้ใน data set
dt = data.Tables[0];
adapter = null;
Connect.DisConnectDB();//ปิดฐานข้อมูล
Connect.objConn = null;//กำหนดค่าว่างให้ตัวแปร objConn
ReportDocument rpt = new ReportDocument();
string directory = AppDomain.CurrentDomain.BaseDirectory;
rpt.Load(directory +"..\\..\\UserCrystalReport.rpt");
rpt.SetDataSource(dt);
this.crystalReportViewer1.ReportSource = rpt;
this.crystalReportViewer1.Refresh();
}
}
}
CrystalDecisions.Shared.CrystalReportsException: Load report failed. ---> System.Runtime.InteropServices.COMException (0x80004005): The system cannot find the file specified.