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 ??
               
            
        }
    }

Sorry.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.