01.
02.
ConnectionInfo info =
new
ConnectionInfo();
03.
04.
info.ServerName =
"ชื่อ server"
;
05.
info.DatabaseName =
"ชื่อฐานข้อมูล"
;
06.
info.UserID =
"ชื่อผู้ล็อคอิน"
;
07.
info.Password =
"รหัสผ่าน"
;
08.
09.
ReportDocument rpt =
new
ReportDocument();
10.
11.
try
{
12.
13.
rpt.Load(reportPath);
14.
15.
16.
foreach
(CrystalDecisions.CrystalReports.Engine.Table table
in
rpt.Database.Tables) {
17.
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
18.
19.
20.
tableLogonInfo.ConnectionInfo = info;
21.
22.
table.ApplyLogOnInfo(tableLogonInfo);
23.
}
24.
}
catch
(Exception ex) {
25.
throw
ex;
26.
}
27.
28.
29.
rpt.SetParameterValue(
"reportTitle"
,
"หัวรายงาน"
);
30.
31.
if
(rpt.HasRecords) {
32.
33.
reportViewer.ReportSource = rpt;
34.
}