Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to dispose a DataSet
Message
From
08/05/2005 22:01:33
 
 
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
01012057
Message ID:
01012067
Views:
21
Hi Kevin,


Here is the code from the main form
private void button1_Click(object sender, System.EventArgs e)
{
frmDialog frmDiag = new frmDialog()
if(frmDiag.showdialog == DiaglogResult.OK)
{
frmDiag.Dispose();
}
}


Now here is the code of the dialog form

public frmDialog()
{
string strConn = "Password=ga;Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=MICHAEL";
string strSql = "Select * from mySampTable";
SqlConnection cn = new SqlConnection(strConn);
SqlDataAdapter da = new SqlDataAdapter(strSql,cn);
DataSet ds = new DataSet();
da.Fill(ds);
this.dataGrid2.DataSource = ds.Tables[0];

cn.Close();
cn.Dispose();
}
Music Rocks www.musicreserve.blogspot.com
Success is 1% Inspiration & 99% Perspiration
God Sometimes Delays His Help to Test Our Faith and Energize Our Prayers
Our Boat May Be Tossed While He Sleeps, But He Wakes Up Before it Sinks.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform