|
Zee Ahmed wrote: How to encrypt an image file ?
The same way you would encrypt anything else. There is nothing special about encrypting image files. A simple search of the internet with ".NET Encryption" will turn up many useful resources.
|
|
|
|
|
Hi, I have a question that I would like for someone to help me with. Because of resource restrictions, I tend to steer away from using try/catch blocks if it is possible.
I just want to know if there is a way of testing whether a connection will open using if statements (maybe using the conn.State/ConnectionState properties) or other methods.
Any suggestions?
|
|
|
|
|
That's really bad practice avoiding try/catch/finally, how do you close an open connection if your code exceptions and you don't have a finally block?
|
|
|
|
|
Using if statements you can pretty much avoid the entire try/catch thing in general. I realize there are certain things that have to be try/catched but most people don't realize how resource intensive try catches can be.
|
|
|
|
|
TheKrazyNomaD wrote: I realize there are certain things that have to be try/catched but most people don't realize how resource intensive try catches can be.
Only if an exception is thrown. They cost nothing if it isn't. Do you expect that the connection will fail sufficiently often that it isn't an exceptional situation but a normal situation?
|
|
|
|
|
TheKrazyNomaD wrote: I just want to know if there is a way of testing whether a connection will open using if statements (maybe using the conn.State/ConnectionState properties) or other methods.
There is no guarantee that it will actually open when requested, even if you are able to check beforehand. In the tiny fraction of a second between your test and actually attempting to open a connection a number of things could happen - such as network failure, the SQL Server being shutdown, the server being rebooted, power failure somewhere between you and the server, etc.
You are better using try/catch/finally to ensure that the connection is actually opened and responding appropriately if it doesn't.
|
|
|
|
|
I agree with Colin. To be honest, you are better off with the couple of extra clock cycles for your try/catch/finally block than you would be if you application falls over in a heap because the time between testing the server connection to the time you open/use the connection, the network goes down/server unplugged from the network, etc.
Do you use the using statement in code? If so, you are using try/finally, e.g.
using (SqlConnection connection = new SqlConnection())
{
...
}
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I have an XML with non-english characters in the property name. My XML is something like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<file>
<city name="New York">
<population>10,000,000</population>
</city>
</file>
Now, instead of "New York", I have "ניו יורק", which is NY in Hebrew. Unfortunately, I cannot change this, and the problem is that the code won't recognize it. The code:
XmlDocument doc = new XmlDocument();
doc.Load("C:\pop.xml");
XmlNode xml = doc.DocumentElement;
string pop = xml.SelectSingleNode("/file/city[@name='" + cityName + "']/pop").InnerText;
Where cityName is New York in Hebrew. I tried changing the NY in all places to English - and the code worked, so I guess it's the Hebrew that is doing the problem.
Any idea how I can resolve this?
Thanks,
Yoni
|
|
|
|
|
Fix the encoding attribute in the <?xml?> tag so it matches the actual encoding of the XML.
|
|
|
|
|
Thanks. For some reason, the ISO-8859-1 wasn't enough, so I changed it to ISO-8859-8.
Yoni
|
|
|
|
|
Use UTF-8 (default of XML). Everything but Unicode (the encodings UTF8, UTF16, or UTF32) is depricated and only supported to allow loading data from legacy programs.
|
|
|
|
|
hi all
i need an implementation of an association rule mining algorithm. (no matter which algorithm)
thanks
|
|
|
|
|
Will this help?
http://www.vldb.org/conf/1995/P432.PDF[^]
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Don't post on multiple boards.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I’m struggling with a thread that should update a TreeView. I’ve started to use the Control.Invoke method when for e.g. adding nodes and so on.
I now wonder how I “Invoke” a property.
(I got the “Cross-thread exeption…” when I try to set the TreeView.ImageIndex property)
_____________________________
...and justice for all
APe
|
|
|
|
|
Either make an accessor method for the property or use the propertyinfo's get's methodinfo to construct a delegate to pass to Control.Invoke
|
|
|
|
|
Do you have any sample code on how to do that?
_____________________________
...and justice for all
APe
|
|
|
|
|
delegate void dAddListItem(string cItem);
private void StartThreadHere()
{
string cListItem="Item2";
if (this.listView1.InvokeRequired)
{
dAddListItem delAddItem = new dAddListItem(AddListItem);
this.listView1.Invoke(delAddItem, cListItem);
}
else
{
this.listView1.Items.Add(cListItem);
}
}
private void AddListItem(string cItemToAdd)
{
this.listView1.Items.Add(cItemToAdd);
}
private void Form1_Load(object sender, EventArgs e)
{
this.listView1.Items.Add("Item1");
Thread t = new Thread(new ThreadStart(StartThreadHere));
t.Start();
}
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Hi all,
I am not too sure where to post my question, so I'll just put it here and hope that somebody will help me. Honestly, I've reached a deadend after searching ALOT. I'll greatly appreciate any help or indication.
The problem:
In Internet Explorer you can right-click on a page and hit "Export to Microsoft Excel". This command is set in the registry (HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Export to Microsoft Excel) to call Excel with "EXCEL.EXE/3000".
The purpose:
I would like to develop a executable with simular functionality: the ability to be called from the internet explorer.
The question:
What is the technology that excel is using? Is it a COM object implementing an interface? How do I do that in .NET? And what on earth is that "/3000" parameter?!?
I've been looking for an answer for quite some time now. Please help.
Rgds,
G.
|
|
|
|
|
Due to the limitation placed on scripting languages due to security I do not believe that would be possible unless you wrapped the IE Browser in your own code, created an ActiveX control, or processed on the server.
Just my thoughts
|
|
|
|
|
Hi Christopher,
Thank you for sharing your thoughts. The main thing that really puzzles me is how it's possible to have a standard executable like Excel.exe being called from IE and work just like a script.
I'll follow your lead and take a closer look into ActiveX control, since I am not very familiar with those and perhaps there is something there.
Rgds,
D.
|
|
|
|
|
Hi again,
I managed to solve this on my own . If anyone is interested in the solution drop me a note on my mailbox..
G.
|
|
|
|
|
connstr = "data source =tm8425\gaurav ;initial catalog=gmcrm;user id=sa;password=maggy;";
sqlConnection conn = new SqlConnection(connstr);
error: unrecognised escape sequence. in tm8425\gaurav
Plz help
Thanks and Regards,
Ahmad
ahmad.osama1984@gmail.com
|
|
|
|
|
try using tm8425\\gaurav
"Change is the only constant thing in life
Either or survive or get extinct"
|
|
|
|
|
Can do like
connstr = @"data source =tm8425\gaurav ;initial catalog=gmcrm;user id=sa;password=maggy;";
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|