|
If your class implemenst IDisposable interface, you can use "using " keyword to avoid disposing explicitly.
using(MyClass obj = new MyClass()){} This method ensures the objects are disposed properly.
|
|
|
|
|
Thanks for the reply.
I have few questions on that...
1. Where to write this...? Creation time of object.?
2. It will throw any error ?
3. If I call obj=null; in the code then any error occurred..?
Note:
Currently I don't have IDisposable interface. Please tell me how to create it..?
Will it work for all type of clasess...?
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
pankaj.indore wrote: Currently I don't have IDisposable interface. Please tell me how to create it..?
Will it work for all type of clasess...?
Then why you are worrying about object disposal ? Is your objects using any unmanaged resources ? If it is not using any unmanaged resources, you need not bother about the garbage collection. .NET framework will do it. If you want to invoke GC all System.GC.Collect()
And writing 800 lines inside a button click make your code a mess. Do you consider breaking it to small functions.
|
|
|
|
|
Breaking code in function is good. I already did it.
But actually I want to know how I know about those object whose are missing to dispose ..? If answer is GC then OK.
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
pankaj.indore wrote: those object whose are missing to dispose
You won' be able to find that, because memory is cleared by GC automatically.
|
|
|
|
|
You can always call GC.Collect() but that is not such a good idea from the performance point of view.
I will use Google before asking dumb questions
|
|
|
|
|
If the object implements IDisposable then you should call Dispose when you finish using it. You can rely on the GC, but the GC might take some time to Dispose of your object. Also generally objects that implement IDisposable are using some limited resource, or unmanaged memory. The GC won't know about this, and what it sees as a trivial object might actually be quite large.
Theres no need to go implementing IDisposable on your own objects for no reason. Just let the GC handle it unless the object implements IDisposable.
|
|
|
|
|
i have one button and one gridview in that i have filled data using
public void GetData()<br />
{ SqlConnection con = new SqlConnection(constr);<br />
string cmd = "select a.errname as ErrorName, m.errortype as ErrorType, a.errpointsdeducted as PointsDeduction, convert(varchar,a.createddate,104) as CreatedDate from auditerrors a,auditerrormaster m where a.errtypeid=m.internalid order by m.errortype";<br />
SqlDataAdapter da = new SqlDataAdapter(cmd,con);<br />
DataSet ds = new DataSet();<br />
DataTable dt = new DataTable();<br />
da.Fill(ds, "auditerrors");<br />
dt = ds.Tables["auditerrors"];<br />
gvAuditErrors.DataSource=ds.Tables[0];<br />
gvAuditErrors.DataBind();}
in the same project i have another page with one text box in it. i want to select a row in the grid view and after selecting a row in grid view when i click on the button i want to transfer the createddate of that particular row in to the textbox of the other page
if anybody got the solution plz do let me know
tasks:
selecting a row on double clicking the row
transfering the content from first page to the other
regards
sunil
-- modified at 5:07 Thursday 22nd November, 2007
|
|
|
|
|
please anybody send me some solution
|
|
|
|
|
I want to send any URL to any web page that may be printed on webpage and also need to be opened in another new web page.
|
|
|
|
|
Why have you posted the same question 3 times, 1 minute apart ?
If you do this, no one will help you as it is considered very rude.
|
|
|
|
|
I want to send any URL to any webpage that may be printed on webpage and also need to be opened in another new web page
|
|
|
|
|
i want to send any URL to any webpage that may be printed on webpage and need to be opened in another new web page
|
|
|
|
|
Hi
I have written a code to uninstall any application. How can this be made better? I mean if a large amount of code can be replaced by smaller one or any other way to uninstall application. Apart from that I have some more questions which I have put in the code itself as comments. Please help on them as well.
Process oProcess = new Process();
oProcess.StartInfo.FileName = "cmd.exe";
oProcess.StartInfo.CreateNoWindow = true;
oProcess.StartInfo.UseShellExecute = false;
RegistryKey oRegKey = null;
string sUninstallString = "";
string[] asSubKeys = Registry.LocalMachine.OpenSubKey(
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\").GetSubKeyNames();
foreach (string sSubKey in asSubKeys) {
oRegKey = Registry.LocalMachine.OpenSubKey(
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + sSubKey);
if (oRegKey.GetValue("Displayname") != null &&
oRegKey.GetValue("Displayname").ToString() == this.treePrograms.SelectedNode.Text) {
sUninstallString = oRegKey.GetValue("Uninstallstring").ToString();
break;
}
}
if (sUninstallString.LastIndexOf("exe") != (sUninstallString.Length - 3)) {
sUninstallString = sUninstallString.Remove(0, 14);
oProcess.StartInfo.Arguments = "/k msiexec.exe /x" + sUninstallString;
}
else {
sUninstallString = sUninstallString.Replace("C:\\", "");
string sExe = sUninstallString.Substring(sUninstallString.LastIndexOf('\\') + 1);
sUninstallString = sUninstallString.Remove(sUninstallString.LastIndexOf('\\'));
oProcess.StartInfo.Arguments = ("/k cd\\ & cd " + sUninstallString + " & " + sExe);
}
oProcess.StartInfo.RedirectStandardError = true;
oProcess.Start();
oProcess.WaitForExit();
oProcess.Close();
oProcess.Dispose();
Also it would be nice if someone can suggest an approach for Add Programs. For me, the major issue would be how to find setups of applications in the system.
Chaos, panic and disorder - my work here is done.
|
|
|
|
|
Hi Guys. Thought I would post this here. I have been struggling getting an export routine to work but had some problems.
1. I wanted to only export data where the Exported Column had a value of 0.
2. When opening the file in Excel I had an error with file format not being the same as file extention.
I have now managed to resolve both issues with some help from the guys in this forumn.
A BIG Thanks to everybody for the help. Below the finished code for the export which can be used by anybody basically.
private void toolStripButton2_Click(object sender, EventArgs e)
{
StreamWriter sw = new StreamWriter(@"C:\file1.csv", false);
DataTable dt = m_dtCC;
int iColCount = dt.Columns.Count;
for (int i = 0; i < iColCount; i++)
{
sw.Write(@"""{0}""", dt.Columns[i]);
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
foreach (DataRow dr in dt.Rows)
{
if (dr["Exported"].ToString() == "0")
{
for (int i = 0; i < iColCount; i++)
{
if (!Convert.IsDBNull(dr[i]))
{
sw.Write(@"""{0}""", dr[i].ToString());
}
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
}
}
sw.Close();
Live to see another day. (",)
|
|
|
|
|
Hi all ,
I can add images to sql and delete from sql server.I wanna update an image data type from sql server.
For example ;
when i click my button it must be get data from picturebox and change binary from sql.
thanx.
|
|
|
|
|
tr_thorn wrote: I can add images to sql and delete from sql server.I wanna update an image data type from sql server.
Well, if you can add images then surely you can update. It is done the same way but with an UPDATE statement.
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
but i cant.. Can ya give me an example for UPDATE STATEMENT IMAGE Data type ?
|
|
|
|
|
My suggestion for programming....
As lot's of programmer do in the world. Please store relative path of image into the database. And save image in any folder.
Storing images into the database is not a good programming aspect. And this will may increase your database size more and more.
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
i know but i want it
|
|
|
|
|
See following URL's
http://www.codeproject.com/aspnet/PicManager.asp
http://www.codeproject.com/cs/database/ImageSaveInDataBase.asp
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
i know save and retrieve. I WANNA DO UPDATE!!! CHANGE BINARY DATA AND PUT A NEW IMAGE THERE.
|
|
|
|
|
For that I also have to search. But another solution is delete that row and insert new one with updated data till you won't found the solution
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
Gnerally add items just is string or string-arrary.
it is not definitely appoint item's value.
how to add combobox's item use code,
the item's text is string, value is int.
the value is appointed definitely.
|
|
|
|
|
Hi,
u can do like this.
ListItem lt =new ListItem("Test1","1");<br />
DropDownList1.Items.Add(lt);<br />
Thanks,
Sun Rays
Rate this post if you like answer.
My Articles
|
|
|
|