Small is New Big in C#


Crytal report print preview

leave a comment »

public SqlConnection getcon()
string M_str_sqlcon = "Server=;Database=ApressFinancial;User id=sa;PWD=";
SqlConnection mycon = new SqlConnection(M_str_sqlcon);
return mycon;

public DataSet getds(string M_str_sqlstr, string M_str_table)
SqlConnection sqlcon = this.getcon();
SqlDataAdapter sqlda = new SqlDataAdapter(M_str_sqlstr, sqlcon);
DataSet myds = new DataSet();
sqlda.Fill(myds, M_str_table);
return myds;

public ReportDocument DailyCrystalReports(string creportName, string sum_sql, System.Data.DataTable tableName)
string P_str_creportPath = System.Windows.Forms.Application.StartupPath.Substring(0, System.Windows.Forms.Application.StartupPath.Substring(0, System.Windows.Forms.Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));
P_str_creportPath += @"\DailyHB\CrReport\" + creportName; //Your report path
ReportDocument doc = new ReportDocument();
return doc;

private void frmDailyCenterIssue_Load(object sender, EventArgs e)
this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = FormBorderStyle.Sizable;

string sum_sql = "SELECT * FROM CenterIssueSummary WHERE SummaryDate = '" + frmSummaryCenterIssue.daily + "' Order By CenterNo"; //Change your sql
DataSet ds = this.GetDs(sum_sql, "CenterIssueSummary"); //Create DataSet
DataTable dt = ds.Tables[0]; //Get Table

crystalReportDaily.ReportSource = this.DailyCrystalReports("SummaryCenterIssue.rpt", sum_sql, sumDt);

Written by nauhil

June 13, 2010 at 10:57 pm

Posted in Tips of C#

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: