Click here to Skip to main content
15,916,378 members
Home / Discussions / C#
   

C#

 
AnswerRe: Reflection question (for <= .NET 3.5) Pin
PIEBALDconsult18-Dec-12 5:17
mvePIEBALDconsult18-Dec-12 5:17 
GeneralRe: Reflection question (for <= .NET 3.5) Pin
MarkB77718-Dec-12 8:53
MarkB77718-Dec-12 8:53 
Questioncrystalreport Pin
mehdi jan17-Dec-12 19:26
mehdi jan17-Dec-12 19:26 
AnswerRe: crystalreport Pin
Mycroft Holmes17-Dec-12 21:22
professionalMycroft Holmes17-Dec-12 21:22 
QuestionFTP Pin
dineshvalluru1116-Dec-12 20:39
dineshvalluru1116-Dec-12 20:39 
AnswerRe: FTP Pin
Sivaraman Dhamodharan16-Dec-12 20:44
Sivaraman Dhamodharan16-Dec-12 20:44 
GeneralRe: FTP Pin
dineshvalluru1116-Dec-12 21:36
dineshvalluru1116-Dec-12 21:36 
GeneralRe: FTP Pin
Richard MacCutchan16-Dec-12 22:08
mveRichard MacCutchan16-Dec-12 22:08 
GeneralRe: FTP Pin
Paul Conrad17-Dec-12 5:59
professionalPaul Conrad17-Dec-12 5:59 
GeneralRe: FTP Pin
Richard MacCutchan17-Dec-12 6:00
mveRichard MacCutchan17-Dec-12 6:00 
GeneralRe: FTP Pin
Marco Bertschi18-Dec-12 1:34
protectorMarco Bertschi18-Dec-12 1:34 
QuestionDataGridView Control Pin
C#_Programmer16-Dec-12 19:51
C#_Programmer16-Dec-12 19:51 
AnswerRe: DataGridView Control Pin
Ingo16-Dec-12 23:36
Ingo16-Dec-12 23:36 
GeneralRe: DataGridView Control Pin
C#_Programmer17-Dec-12 1:26
C#_Programmer17-Dec-12 1:26 
GeneralRe: DataGridView Control Pin
Dave Kreskowiak17-Dec-12 3:13
mveDave Kreskowiak17-Dec-12 3:13 
AnswerRe: DataGridView Control Pin
PIEBALDconsult17-Dec-12 3:32
mvePIEBALDconsult17-Dec-12 3:32 
Questionenum question Pin
Blubbo16-Dec-12 16:13
Blubbo16-Dec-12 16:13 
AnswerRe: enum question Pin
PIEBALDconsult16-Dec-12 17:26
mvePIEBALDconsult16-Dec-12 17:26 
GeneralRe: enum question Pin
Blubbo16-Dec-12 18:27
Blubbo16-Dec-12 18:27 
QuestionMySqlParameter... Add or AddWithValue? Pin
Jassim Rahma16-Dec-12 7:03
Jassim Rahma16-Dec-12 7:03 
AnswerRe: MySqlParameter... Add or AddWithValue? Pin
Mycroft Holmes16-Dec-12 11:54
professionalMycroft Holmes16-Dec-12 11:54 
AnswerRe: MySqlParameter... Add or AddWithValue? Pin
PIEBALDconsult16-Dec-12 12:39
mvePIEBALDconsult16-Dec-12 12:39 
AnswerRe: MySqlParameter... Add or AddWithValue? Pin
GREG_DORIANcod19-Dec-12 4:38
professionalGREG_DORIANcod19-Dec-12 4:38 
QuestionTry catch finally Pin
Claudiu Schiopu16-Dec-12 5:53
Claudiu Schiopu16-Dec-12 5:53 
Hi,

Maby this is simple for you, but for me is not.
I have this code:

C#
int rezultat = 0;
           try
           {
               if (sqlconn.State != ConnectionState.Open)
               {
                   sqlconn.Open();
               }
               rezultat = (int)cmd.ExecuteScalar();

           }
           catch (Exception ex)
           {
               lblMesaje.Text = "Eroare: " + ex.Message.ToString();

           }
           finally
           {
               if (sqlconn.State != ConnectionState.Closed)
               {
                   sqlconn.Close();
               }
           }

           return rezultat;


Is just for inserting a new record in a table. Even if this throw an error "Specified cast is not valid." "rezultat=(int)cmd.ExecuteScalar();" - the code is executed and the row is inserted in the database, and the execution continues.

Why it continues?
Maby i don't understand the try catch finally yet Smile | :)

Thank you!
AnswerRe: Try catch finally Pin
OriginalGriff16-Dec-12 5:59
mveOriginalGriff16-Dec-12 5:59 

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.