Ejemplo n.º 1
0
        public bool Update()
        {
            try
            {
                var ds2 = dataSet.GetChanges();
                if (ds2 != null)
                {
                    if (ds2.HasErrors)
                    {
                        MessageBox.Show("Errori");
                    }
                    if (ds2.HasChanges())
                    {
                        AddTransaction();
                        CreateUpdateCommand();

                        sqlDA.Update(dataSet, myTable);
                    }
                }
            }
            catch (SqlException e)
            {
                Trace.Write(e.Message);
                Debug.Assert(false);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private static bool WriteData(string tableName, DataSet dataSet)
        {
            var query = $"SELECT * FROM {tableName}";

            using (var sqlCM = new SqlProxyCommand(query, GlobalInfo.DBaseInfo.dbManager.DB_Connection))
            {
                var adp = new SqlProxyDataAdapter(sqlCM);
                var scb = new SqlProxyCommandBuilder(adp);
                try
                {
                    adp.InsertCommand = scb.GetInsertCommand();
                    var rows = adp.Update(dataSet, dataSet.Tables[0].TableName);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e.StackTrace, e.Message);
                    MessageBox.Show(e.StackTrace, e.Message);
                }
                finally
                {
                }
            }

            return(true);
        }