Saturday, March 30, 2013

how to Add Multiple Value in a Variable In SQL Server


declare @Pipno table(V_3 varchar(500),V_2 varchar(10))

insert into @Pipno (V_3)
Select  COUNT(IMEINo)
 FROM  Jobsheet
WHERE    (ModCode ='H057') AND (ServiceCentreCd ='C009')
 GROUP BY IMEINo,ModCode
HAVING      (COUNT(IMEINo)> 1)
update @Pipno set V_2=1
 Select * from @Pipno

Tuesday, March 19, 2013

How to Export Crystal report in Excel in ASP.Net

private void printreportinExcel(string strReportPath, DataTable dt)
{
//strReportPath  is the report path, dt is the datatable
ReportDocument rptdoc = new ReportDocument();
rptdoc.Load(Server.MapPath(strReportPath));
rptdoc.SetDataSource(dt);

ExportOptions exportOpts1 = rptdoc.ExportOptions;rptdoc.ExportOptions.ExportFormatType =
ExportFormatType.Excel;rptdoc.ExportOptions.ExportDestinationType =
ExportDestinationType.DiskFile;rptdoc.ExportOptions.DestinationOptions =
new DiskFileDestinationOptions();((
DiskFileDestinationOptions)rptdoc.ExportOptions.DestinationOptions).DiskFileName = Server.MapPath("swapt.xls");rptdoc.Export();
rptdoc.Close();
rptdoc.Dispose();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType =
"vendor/ms-excel";Response.AppendHeader(
"Content-Disposition", "attachment; filename=swapt_Report.xls");Response.WriteFile(
"swapt.xls");Response.Flush();
Response.Close();

File.Delete(Server.MapPath("swapt.xls"));}