Click here to Skip to main content
15,908,909 members
Home / Discussions / C#
   

C#

 
QuestionMessage Box Office 2003 Style Pin
sahaas4-Aug-06 8:24
sahaas4-Aug-06 8:24 
AnswerRe: Message Box Office 2003 Style Pin
Judah Gabriel Himango4-Aug-06 11:22
sponsorJudah Gabriel Himango4-Aug-06 11:22 
QuestionOverriding Dispose(bool disposing) in designer file? Pin
wout de zeeuw4-Aug-06 7:50
wout de zeeuw4-Aug-06 7:50 
AnswerRe: Overriding Dispose(bool disposing) in designer file? Pin
LongRange.Shooter4-Aug-06 9:12
LongRange.Shooter4-Aug-06 9:12 
GeneralRe: Overriding Dispose(bool disposing) in designer file? Pin
wout de zeeuw4-Aug-06 9:29
wout de zeeuw4-Aug-06 9:29 
GeneralRe: Overriding Dispose(bool disposing) in designer file? [modified] Pin
LongRange.Shooter4-Aug-06 9:37
LongRange.Shooter4-Aug-06 9:37 
GeneralRe: Overriding Dispose(bool disposing) in designer file? Pin
wout de zeeuw4-Aug-06 9:47
wout de zeeuw4-Aug-06 9:47 
Questiontry catch finally Pin
Saamir4-Aug-06 7:42
Saamir4-Aug-06 7:42 
Hi guys,
I am a newbie in C# and I need some help. If I open a database connection in my try statement, can I close it in finally. i.e. is finally always executed?

This is what I have; is this a good programming technique?

Please help
public int validateGLAccount(string Number)
{
//bool rt=true;
SqlConnection cnn=null;
SqlCommand cmd=null;
try
{
cnn=new SqlConnection(m_Cnn);
cnn.Open();
if (true)
{
cmd= new SqlCommand("SELECT count(ID) FROM table",cnn);
one = (int)cmd.ExecuteScalar();
if (one==1)
{
return -1;
}
else
{
return 1;
}
}
else
{
return -1;
}
}
catch(Exception ex)
{
MessageBox.Show(this,ex.Message);
}
finally
{
cmd=null;
if(cnn!=null && cnn.State !=ConnectionState.Closed)
{
cnn.Close();
}
cnn=null;
}
return -1;
}

sasa

AnswerRe: try catch finally Pin
wout de zeeuw4-Aug-06 7:46
wout de zeeuw4-Aug-06 7:46 
GeneralRe: try catch finally Pin
Saamir4-Aug-06 7:50
Saamir4-Aug-06 7:50 
AnswerRe: try catch finally Pin
Glen Harvy4-Aug-06 13:17
Glen Harvy4-Aug-06 13:17 
QuestionCreate "aspx" code for a control Pin
bdn024-Aug-06 6:54
bdn024-Aug-06 6:54 
QuestionCombo Box binding Pin
~~~Johnny~~~4-Aug-06 6:47
~~~Johnny~~~4-Aug-06 6:47 
AnswerRe: Combo Box binding Pin
Josh Smith4-Aug-06 7:21
Josh Smith4-Aug-06 7:21 
GeneralRe: Combo Box binding Pin
~~~Johnny~~~4-Aug-06 8:00
~~~Johnny~~~4-Aug-06 8:00 
QuestionHow to access an object stored in the Tag property Pin
Subterranean4-Aug-06 6:43
Subterranean4-Aug-06 6:43 
AnswerRe: How to access an object stored in the Tag property Pin
LongRange.Shooter4-Aug-06 6:47
LongRange.Shooter4-Aug-06 6:47 
QuestionEncrypt Pin
seee sharp4-Aug-06 6:14
seee sharp4-Aug-06 6:14 
Questionhow to print form and how to print maltiple pages?? Pin
hdv2124-Aug-06 4:29
hdv2124-Aug-06 4:29 
AnswerRe: how to print form and how to print maltiple pages?? Pin
Judah Gabriel Himango4-Aug-06 5:10
sponsorJudah Gabriel Himango4-Aug-06 5:10 
GeneralRe: how to print form and how to print maltiple pages?? Pin
hdv2124-Aug-06 11:06
hdv2124-Aug-06 11:06 
QuestionSerial port power Pin
hacker0134-Aug-06 4:18
hacker0134-Aug-06 4:18 
AnswerRe: Serial port power Pin
Stefan Troschuetz4-Aug-06 4:43
Stefan Troschuetz4-Aug-06 4:43 
AnswerRe: Serial port power Pin
stancrm4-Aug-06 6:15
stancrm4-Aug-06 6:15 
AnswerRe: Serial port power Pin
eggie55-Aug-06 20:53
eggie55-Aug-06 20:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.