Export Table from Sql Server to PDF file using c# -


i have few tables in sql , want export them pdf file after click form button knows how can it?

i have code when export table sql excel:

protected void insertbtn(object sender, eventargs e) { string constring = @"data source =xxxx; initial catalog=xxxx;     persist security     info=true;user id=xxxx; password=xxxx";sqlconnection sqlcon     = new     sqlconnection(constring); sqlcon.open();  sqldataadapter da = new sqldataadapter("select * injuryscenario", sqlcon); system.data.datatable dtmainsqldata = new system.data.datatable(); da.fill(dtmainsqldata); datacolumncollection dccollection = dtmainsqldata.columns; // export data excel sheet microsoft.office.interop.excel.applicationclass excelapp = new                                             microsoft.office.interop.excel.applicationclass(); excelapp.application.workbooks.add(type.missing); // excelapp.cells.copyfromrecordset(objrs); (int = 1; < dtmainsqldata.rows.count + 2; i++) {     (int j = 1; j < dtmainsqldata.columns.count + 1; j++)     {         if (i == 1)         {             excelapp.cells[i, j] = dccollection[j - 1].tostring();         }         else             excelapp.cells[i, j] = dtmainsqldata.rows[i - 2][j - 1].tostring();     } } excelapp.activeworkbook.savecopyas("c:\\users\\mor shivek\\desktop\\test.xls"); excelapp.activeworkbook.saved = true; excelapp.quit(); } 

what mean "export pdf"? wouldn't easiest way use excel export above , sending print command file using pdf printer? if want create pdf natively have effort layout document.

//edit: little research on have brought well: best c# api create pdf


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -