DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   Problems with transaction in SQL Server Mobile (http://www.daniweb.com/forums/thread167702.html)

Dav1d1 Jan 11th, 2009 10:14 am
Problems with transaction in SQL Server Mobile
 
Hello

I try pass data from a table in Firebird to SQL server Mobile. I'm using c# in vs2005, and I have problems with transactions. At the end, if I want to rollback transaction, I would like to undo changes, but in the code I show you, Changes allways saves in database.

Why doesn't rollback works ?

public class MoveData
    {
   

        private SqlCeConnection conection;
        private SqlCeTransaction trans;
        private SqlCeDataAdapter command;

        public MoveData(String path)
        {
           
            conection = new SqlCeConnection(@"Data Source=D:\MyDataBase.sdf");
            conection.Open();
        }

        public void MovingData()
        {
           
         
            //It's a empty table
            command = new SqlCeDataAdapter("SELECT * FROM INVOICE", conection);
            DataSet dataSet = new DataSet();

            DataSet dataSet = new DataSet();
            command.Fill(dataSet, "INVOICE");
            DataTable TINVOICE = dataSet.Tables["INVOICE"];
            trans = conection.BeginTransaction();
       

            foreach (DataRow row in TINVOICEotherdatabasetable.Rows)
            {
             
                DataRow row1 = TINVOICE.NewRow();
                foreach(DataColumn column in TINVOICEotherdatabasetable.Columns)
                {
                    row1[column.ColumnName] = row[column.ColumnName];
                 
                }
                TINVOICE.Rows.Add(row1);

            }
         
              SqlCeCommandBuilder commands = new SqlCeCommandBuilder(command);
                command.Update(dataSet,"INVOICE"); //here save me changes in database
                trans.Rollback();// this Rollback doesn't work, Why ??
             
           
        }
    }

ddanbe Jan 11th, 2009 2:50 pm
Re: Problems with transaction in SQL Server Mobile
 
Sorry.

Ramy Mahrous Jan 11th, 2009 3:20 pm
Re: Problems with transaction in SQL Server Mobile
 
Have a look http://msdn.microsoft.com/en-us/libr...ck(VS.80).aspx
It may should be defined in IsolationLevel member... I don't know I need to help, wish for you th best..


All times are GMT -4. The time now is 5:30 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC