TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nalin Aggarwal
NA
1
836
Crystal report Code is not working
Dec 23 2014 1:53 PM
When I am running the below code on local database and exporting it to pdf, it's working fine but at the time when I connecting the database online it's neither showing the result and again & again showing the LogOn screen.In this using the dynamic parameters of crystal report.
string
conn_string
=
string
.
Empty
;
ReportClass
rc
;
NameValueCollection
plist
;
string
reportName
;
string
proc
;
protected
void
Page_Load
(
object
sender
,
EventArgs
e
)
{
conn_string=
ConfigurationManager
.
ConnectionStrings
[
"sapphiredbConnectionString"
].
ConnectionString
;
NameValueCollection
pList
=
new
NameValueCollection
();
reportName
=
Request
.
QueryString
[
"Report"
];
pList
=
(
NameValueCollection
)
Session
[
"Parameter1"
];
proc
=
Request
.
QueryString
[
"data"
];
if
(!
IsPostBack
)
LoadReport
(
reportName
,
pList
,
proc
);
}
public
void
LoadReport
(
string
reportName
,
NameValueCollection
pList
,
string
proc
)
{
rc
=
new
ReportClass
();
rc
.
FileName
=
Server
.
MapPath
(
reportName
);
IMConnectionInfo
info
=
new
IMConnectionInfo
(
conn_string
);
foreach
(
CrystalDecisions
.
CrystalReports
.
Engine
.
Table
mytable
in
rc
.
Database
.
Tables
)
{
TableLogOnInfo
myLoginfo
=
new
TableLogOnInfo
();
myLoginfo
.
ConnectionInfo
.
ServerName
=
info
.
ServerName
;
myLoginfo
.
ConnectionInfo
.
IntegratedSecurity
=
info
.
IntegratedSecurity
;
myLoginfo
.
ConnectionInfo
.
DatabaseName
=
info
.
DatabaseName
;
if
(!
info
.
IntegratedSecurity
)
{
myLoginfo
.
ConnectionInfo
.
UserID
=
info
.
UserName
;
myLoginfo
.
ConnectionInfo
.
Password
=
info
.
Password
;
}
mytable
.
ApplyLogOnInfo
(
myLoginfo
);
}
foreach
(
ParameterField
pf
in
rc
.
ParameterFields
)
{
ParameterDiscreteValue
pdv
=
new
ParameterDiscreteValue
();
if
(
plist
!=
null
)
{
foreach
(
string
k
in
plist
.
Keys
)
{
if
(
k
==
pf
.
Name
)
{
pdv
.
Value
=
plist
.
Get
(
k
);
pf
.
CurrentValues
.
Add
(
pdv
);
}
}
}
}
CrystalReportViewer1
.
ReportSource
=
rc
;
CrystalReportViewer1
.
ShowAllPageIds
=
true
;
CrystalReportViewer1
.
Visible
=
true
;
}
Reply
Answers (
0
)
Show the data associated with logged on users
c# to javascript