Click here to Skip to main content
15,922,696 members
Home / Discussions / C#
   

C#

 
Questiondetect mass storage devices Pin
Jassim Rahma22-Feb-09 21:57
Jassim Rahma22-Feb-09 21:57 
AnswerRe: detect mass storage devices Pin
Christian Graus22-Feb-09 21:58
protectorChristian Graus22-Feb-09 21:58 
GeneralRe: detect mass storage devices Pin
Jassim Rahma22-Feb-09 22:26
Jassim Rahma22-Feb-09 22:26 
QuestionA Question About MSMQ(Microsoft Message Queue) Pin
Jason_Shen22-Feb-09 21:45
Jason_Shen22-Feb-09 21:45 
AnswerRe: A Question About MSMQ(Microsoft Message Queue) Pin
Jason_Shen23-Feb-09 2:25
Jason_Shen23-Feb-09 2:25 
GeneralRe: A Question About MSMQ(Microsoft Message Queue) Pin
Jimmanuel23-Feb-09 3:35
Jimmanuel23-Feb-09 3:35 
GeneralRe: A Question About MSMQ(Microsoft Message Queue) Pin
Jason_Shen23-Feb-09 6:10
Jason_Shen23-Feb-09 6:10 
GeneralRe: A Question About MSMQ(Microsoft Message Queue) Pin
Jimmanuel23-Feb-09 6:58
Jimmanuel23-Feb-09 6:58 
GeneralRe: A Question About MSMQ(Microsoft Message Queue) Pin
Jason_Shen23-Feb-09 15:30
Jason_Shen23-Feb-09 15:30 
GeneralRe: A Question About MSMQ(Microsoft Message Queue) Pin
Jimmanuel23-Feb-09 16:05
Jimmanuel23-Feb-09 16:05 
GeneralRe: A Question About MSMQ(Microsoft Message Queue) Pin
Jason_Shen23-Feb-09 16:26
Jason_Shen23-Feb-09 16:26 
GeneralRe: A Question About MSMQ(Microsoft Message Queue) Pin
Jimmanuel24-Feb-09 1:00
Jimmanuel24-Feb-09 1:00 
QuestionCrystal Pin
Stephen Lintott22-Feb-09 21:30
Stephen Lintott22-Feb-09 21:30 
Questionconnecting remote mysql database using c#.net Pin
dilip51422-Feb-09 20:04
dilip51422-Feb-09 20:04 
AnswerRe: connecting remote mysql database using c#.net Pin
dan!sh 22-Feb-09 20:11
professional dan!sh 22-Feb-09 20:11 
AnswerRe: connecting remote mysql database using c#.net Pin
Christian Graus22-Feb-09 21:04
protectorChristian Graus22-Feb-09 21:04 
AnswerRe: connecting remote mysql database using c#.net Pin
EliottA23-Feb-09 2:47
EliottA23-Feb-09 2:47 
QuestionCheckbox Pin
mrithula822-Feb-09 19:33
mrithula822-Feb-09 19:33 
AnswerRe: Checkbox Pin
dan!sh 22-Feb-09 19:50
professional dan!sh 22-Feb-09 19:50 
AnswerRe: Checkbox Pin
Eslam Afifi22-Feb-09 19:52
Eslam Afifi22-Feb-09 19:52 
AnswerRe: Checkbox Pin
RobScripta23-Feb-09 7:27
professionalRobScripta23-Feb-09 7:27 
QuestionProblem in Multiple Insertion with TransactionScope. Pin
hdv21222-Feb-09 18:59
hdv21222-Feb-09 18:59 
Hi i have a dagaridview view bind to an empty dataTable, user can insert values directly into datagridview and then click Save. when user clicked Save button, i write this code to iterate through dataTable records and insert to my database in transaction mode :

using (SqlConnection con = new SqlConnection("data source=.;initial catalog=test;Trusted_Connection=Yes"))
            {
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandText = "insert Person(titleId,fname,lname) values(@titleId,@fname,@lname)";
                con.Open();

                System.Transactions.TransactionOptions trOptions = new System.Transactions.TransactionOptions();
                trOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
                trOptions.Timeout = new TimeSpan(0, 0, 15);
                using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, trOptions))
                {
                    try
                    {
                        foreach (DataRow row in this.dt1.Rows)
                        {

                            int titleId = int.Parse(row["titleId"].ToString()); // cause error
                            string fname = row["fname"].ToString();
                            string lname = row["lname"].ToString();

                            if (cmd.Parameters.Count > 0)
                                cmd.Parameters.Clear();

                            cmd.Parameters.AddWithValue("@titleId", titleId);
                            cmd.Parameters.AddWithValue("@fname", fname);
                            cmd.Parameters.AddWithValue("@lname", lname);
                            cmd.ExecuteNonQuery();

                        }
                        con.Close();
                        ts.Complete();
                    }
                    catch (Exception ex)
                    {

                    }                    
                }
            }

I want, all of insertion execute in transation, for test, at runTime i was entered correct row in first datagridview row and then entered incorrect row in second with cause exception, but at runTime the first records has been inserted wheras i want when error has occured, all inserted records rollback.
Can anybody help me ?
Thanks
AnswerRe: Problem in Multiple Insertion with TransactionScope. Pin
dan!sh 22-Feb-09 20:04
professional dan!sh 22-Feb-09 20:04 
GeneralRe: Problem in Multiple Insertion with TransactionScope. Pin
hdv21224-Feb-09 0:06
hdv21224-Feb-09 0:06 
QuestionAbout Restricted method Pin
rajanbabu_03322-Feb-09 18:49
rajanbabu_03322-Feb-09 18:49 

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.