[the windows-app-sdk Tag is irrelevant]
Use "using" to automatically close connection, as explained in MSDN samples : SqlConnection.Close Method
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I've successful shown a Windows Forms SAP Crystal Report. I'm using
to store the value, then display
This is my code,
private void frmIncidentMaster_GetIncidents_Show_Load(object sender, EventArgs e)
{
BindReport();
}
private void BindReport()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConn"].ConnectionString);
try
{
SqlCommand cmd = new SqlCommand("select * from [dbo].[rptIncidentMaster_GetIncidents] " +
"Where Batch_Id = '" + paramData.Batch_Id + "'", con);
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "rptIncidentMaster_GetIncidents");
IncidentMaster_GetIncidents rpt = new IncidentMaster_GetIncidents();
rpt.SetDataSource(ds);
crystalReportViewer1.ReportSource = rpt;
crystalReportViewer1.RefreshReport();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
}
Is this the best practice? No need to close connection & dispose connection? No need to dispose Crystal Report Object ?
Last time I'm using Data Adapter and Data Set in Active Server Pages ( ASP Classic ) Programming. Then, no more
If Windows Forms having new technology to retrieve value then send it into Crystal Report View, please tell me. May be I'm a overlook
Please help
[the windows-app-sdk Tag is irrelevant]
Use "using" to automatically close connection, as explained in MSDN samples : SqlConnection.Close Method