Monday, January 10, 2011

Asp.net ReportViewer how to clear if no records found

asp.net report viewer, if initially load all records then if you are changing the filter and your result returns no records means you can see what you got last result it will maintain in report viewer how you can clear,following sample code will help

Sample code :
------------------

Reportviewer1.Reset();

REportviewer1.LocalReport.Refresh();

Asp.net Gridview Page Size Increase Dynamically

Asp.net Run time How We can increase page size dynamically using Gridview PageSizeChangeEventArgs event we can achieve the dynamic page Size , following code will explain


Sample Code:
protected void gv1_PageSizeChange(object sender, PageSizeChangeEventArgs e)

{

gv1.PageSize= e.NewPageSize;

gv1.PageIndex = 0;

BindGrid();

}

asp.net using Crystal report opening pdf inside the web page

Following code will explain asp.net without asking open prompt ,automatically open the pdf file inside aspx

sample Code:
=============


public class WebForm1 : System.Web.UI.Page
{
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
protected System.Web.UI.WebControls.Button Button1;
private CrystalReport1 report = new CrystalReport1();
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
CrystalReportViewer1.ReportSource = report;
CrystalReportViewer1.Visible = true;
}





-

private void Button1_Click(object sender, System.EventArgs e)
{
MemoryStream oStream; // using System.IO
oStream = (MemoryStream)
report.ExportToStream(
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(oStream.ToArray());
Response.End();
}

Sql Server Get table data (.csv) excuting bat file

How To get sql server Table all records in Csv file by excuting .bat file in Client machine

sample Bat file

1)Open Notepad

2)SQLCMD -S .\SQLEXPRESS -d DatabaseName -E -Q "select * from tableName" -o "FileName.csv" -h-1 -s"," -w 700

3)save as .bat File