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
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Export all Files in PDF Format at a Time using C#
Rajkiran Swain
Jun 05
2015
Code
1.4
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
public
void
updatestaus(
string
F)
{
sc.Close();
sc.Open();
SqlCommand cmd =
new
SqlCommand(
"update BOND_REG set status='P' where fliono='"
+ F +
"'"
, sc);
cmd.ExecuteNonQuery();
sc.Close();
}
protected
void
Button2_Click(
object
sender, EventArgs e)
{
sc.Open();
SqlCommand cmd =
new
SqlCommand(
"select Fliono from BOND_REG where status='A'"
, sc);
SqlDataReader SDR = cmd.ExecuteReader();
while
(SDR.Read() ==
true
) {
string
St = SDR.GetValue(0).ToString();
//SDR.Close();
// SDR.Dispose();
fileexport(St);
updatestaus(St);
}
SDR.Close();
sc.Close();
}
public
void
fileexport(
string
st1)
{
// SDR.Close();
SqlCommand cmd1 =
new
SqlCommand(
"select * from BOND_REG where status='A' and Fliono='"
+ st1 +
"'"
, sc);
SqlDataAdapter da =
new
SqlDataAdapter();
da.SelectCommand = cmd1;
DataTable datatable =
new
DataTable();
da.Fill(datatable);
ReportDocument crystalReport =
new
ReportDocument();
crystalReport.Load(Server.MapPath(
"~/bond.rpt"
));
crystalReport.SetDataSource(datatable);
ExportOptions rptExportOption;
DiskFileDestinationOptions rptFileDestOption =
new
DiskFileDestinationOptions();
PdfRtfWordFormatOptions rptFormatOption =
new
PdfRtfWordFormatOptions();
string
reportFileName = @
"C:\pdfd\ st1.pdf"
;
rptFileDestOption.DiskFileName = reportFileName;
rptExportOption = crystalReport.ExportOptions;
{
rptExportOption.ExportDestinationType = ExportDestinationType.DiskFile;
rptExportOption.ExportFormatType = ExportFormatType.PortableDocFormat;
rptExportOption.ExportDestinationOptions = rptFileDestOption;
rptExportOption.ExportFormatOptions = rptFormatOption;
}
crystalReport.Export();
}
C#
PDF
Export all Files in PDF Format