|
-
Oct 6th, 2003, 04:29 AM
#1
Thread Starter
Hyperactive Member
How to use finally()**SOLVED**
Hey folks, me again with a simple(at least I hope) problem. How do I use the finally clause! Heres what I am trying to do :
I open up a connection to a database, and want to close that conn in my finally block, heres my code
Code:
public string response_message(string message)
{
SqlConnection conn;
try
{
conn = new SqlConnection(sConn);
}
catch
{
}
finally
{
conn.Close();
}
}
Trying to compile this code i get an error saying it doesnt know the variable conn.
So how can I use that connection in my finally block?
Thanx in advance,
Stephan
Last edited by Sgt-Peppa; Oct 6th, 2003 at 04:38 AM.
Keep Smiling - even if its hard 
Frankie Says Relax, wossname Says Yeah!
wossname:--Currently I'm wearing a gimp suit and a parachute.
C# - Base64 Blog
-
Oct 6th, 2003, 04:39 AM
#2
Thread Starter
Hyperactive Member
ups, found my mistake, had to assign a value to conn. So I assigned null, for all interested!
Thanx, Stephan
Keep Smiling - even if its hard 
Frankie Says Relax, wossname Says Yeah!
wossname:--Currently I'm wearing a gimp suit and a parachute.
C# - Base64 Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|