using Microsoft.VisualBasic;
using System;
using System.Collections;
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.Configuration;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using System.Diagnostics;
using System.IO;
namespace Disbursed
{
public partial class ReportPrint : Form
{
//Variable Type or new object
SqlConnection conn = new SqlConnection();
DataSet ds = new DataSet();
DataTable dt = null;
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand();
public ReportPrint()
{
InitializeComponent();
}
private void ReportPrint_Load(object sender, EventArgs e)
{
//Connecting your database = App.config("AppName")
ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings["ApplicationDatabase"];
string ConnectionStrings = conSettings.ConnectionString;
conn = new SqlConnection(ConnectionStrings);
conn.Open();
string sql = null;
sql = "SELECT * FROM CommiteeReq";
SqlCommand cmd = new SqlCommand(sql, conn);
da.SelectCommand = cmd;
ds.Clear();
da.Fill(ds, "CommiteeReqReport");
dt = ds.Tables[0];
da = null;
conn.Close();
conn = null;
ReportDocument ReportDis = new ReportDocument();
string directory = AppDomain.CurrentDomain.BaseDirectory;
ReportDis.Load(directory + "\\CrystalReportDis.rpt"); // Path การเรียกใช้บรรทัดนี้มัน Error ครับ
//ReportDis.Load("D:\\Disbursed\\CrystalReportDis.rpt");
ReportDis.SetDataSource(dt);
this.crystalReportViewer1.ReportSource = ReportDis;
this.crystalReportViewer1.Refresh();
}
}
}
Tag : .NET, Ms SQL Server 2008, Win (Windows App), C#