コード例 #1
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);
        }
コード例 #2
0
 private void CreateConnection()
 {
     sqlCM = new SqlProxyCommand(sqlCN);
     AddParameters();
     sqlCM.CommandText = CreateQuery();
     sqlDA             = new SqlProxyDataAdapter(sqlCM);
 }
コード例 #3
0
        private void SetDataAdapterTransaction(SqlProxyDataAdapter dataAdapter)
        {
            if (!globalPref.UseTransaction || SqlProxyTransaction == null)
            {
                return;
            }

            dataAdapter.InsertCommand.Transaction = SqlProxyTransaction;
            dataAdapter.DeleteCommand.Transaction = SqlProxyTransaction;
            dataAdapter.SelectCommand.Transaction = SqlProxyTransaction;
            dataAdapter.UpdateCommand.Transaction = SqlProxyTransaction;
        }
コード例 #4
0
        private static DataSet ReadData(string tableName)
        {
            var dataSet = new DataSet();
            var query   = $"SELECT * FROM {tableName}";

            using (var sqlCM = new SqlProxyCommand(query, GlobalInfo.DBaseInfo.dbManager.DB_Connection))
            {
                var sqlDA = new SqlProxyDataAdapter(sqlCM);
                sqlDA.Fill(dataSet, tableName);
            }

            return(dataSet);
        }
コード例 #5
0
        private static void CreateCommand(SqlProxyDataAdapter dAdapter)
        {
            var cBuilder = new SqlProxyCommandBuilder(dAdapter)
            {
                QuotePrefix    = "[",
                QuoteSuffix    = "]",
                ConflictOption = ConflictOption.CompareRowVersion
            };

            dAdapter.UpdateCommand = cBuilder.GetUpdateCommand();
            dAdapter.InsertCommand = cBuilder.GetInsertCommand();
            dAdapter.DeleteCommand = cBuilder.GetDeleteCommand();
        }
コード例 #6
0
        private void CreateConnection()
        {
            rdrDataSet        = new DataSet("GridDataSet");
            rdrFindSqlCommand = new SqlProxyCommand()
            {
                Connection = rdrConnection
            };

            rdrBrowseSqlCommand = new SqlProxyCommand
            {
                Connection = rdrConnection
            };
            rdrParameters = new SqlProxyParameterCollection(rdrBrowseSqlCommand);

            rdrBrowseSqlCommand.CommandText = DefineBrowseQuery(rdrBrowseSqlCommand, string.Empty);
            rdrDataAdapter = new SqlProxyDataAdapter(rdrBrowseSqlCommand);
        }
コード例 #7
0
        private SqlProxyDataAdapter CreateDataAdapter(string name, SqlProxyCommand sqlCommand)
        {
            SqlProxyDataAdapter dAdapter = null;

            dAdapter = new SqlProxyDataAdapter(sqlCommand);

            try
            {
                dAdapter.FillSchema(Dataset, SchemaType.Source);
                dAdapter.Fill(Dataset, name);
                SetDefaultValue(name);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }

            return(dAdapter);
        }
コード例 #8
0
        static void Main(string[] args)
        {
            var result = GetDBType(typeof(String));

            ProxyProviderLoader.UseProvider = ProviderType.SQL;
            //var list = SqlProxyDatabaseHelper.ListDatabase("USR-ROGLEDIMAU1", "sa", "", true);

            var sqlconnectiostring = new SqlProxyConnectionStringbuilder
            {
                DataSource = @"SALA\SQLEXPRESS",
                //UserID = "sa",
                InitialCatalog = "PLUMBER",
                //Password = "******",
                IntegratedSecurity = true
            };

            //var creadb = new SqlProxyDataBaseHelper
            //{
            //    DataSource = @"C:\Users\Rogledi\Desktop\Clothes.db"
            //};
            //creadb.CreateDatabase();

            //var creadb = new SqlProxyCreateDatabase
            //{
            //    DataSource = "USR-ROGLEDIMAU1",
            //    UserID = "sa",
            //    InitialCatalog = "PROVADB",
            //};
            //creadb.CreateDatabase();

            SqlProxyDatabaseHelper.Password = "******";

            //var sqlconnectiostring = new SqlProxyConnectionStringbuilder
            //{
            //    DataSource = @"USR-ROGLEDIMAU1",
            //    UserID = "sa",
            //    InitialCatalog = "NORTHWIND"
            //};

            //ProxyProviderLoader.UseProvider = ProviderType.SQLite;
            //var sqlconnectiostring = new SqlProxyConnectionStringbuilder
            //{
            //    DataSource = @"D:\Utenti\Mauro\Desktop\Clothes.db"
            //};

            using (var connection = new SqlProxyConnection(sqlconnectiostring.ConnectionString))
            {
                connection.Open();

                {
                    // var transaction = connection.BeginTransaction();
                    var p1 = new SqlProxyParameter("@p1", DbType.String, 16)
                    {
                        Value = "ARDUINO"
                    };

                    //var p1 = new SqlProxyParameter("@p1", DbType.Int16)
                    //{
                    //    Value = 1
                    //};

                    //var p1 = new SqlProxyParameter("@p1", DbType.String, 5)
                    //{
                    //    Value = "ALFKI"
                    //};

                    var dataSet = new DataSet();
                    //using (var sqlCmd = new SqlProxyCommand("SELECT * FROM CUSTOMERS where CustomerID = @p1"))
                    //using (var sqlCmd = new SqlProxyCommand("SELECT * FROM CL_MASTER where ID = @p1", connection))
                    using (var sqlCmd = new SqlProxyCommand(connection))
                    {
                        var p2 = sqlCmd.Parameters.Add(p1);
                        sqlCmd.CommandText = "SELECT * FROM PL_MASTERS where Code = @p1";
                        var dAdapter = new SqlProxyDataAdapter()
                        {
                            SelectCommand = sqlCmd
                        };

                        var cBuilder = new SqlProxyCommandBuilder(dAdapter)
                        {
                            QuotePrefix    = "[",
                            QuoteSuffix    = "]",
                            ConflictOption = ConflictOption.CompareRowVersion
                        };
                        //dAdapter.UpdateCommand = cBuilder.GetUpdateCommand();
                        dAdapter.InsertCommand = cBuilder.GetInsertCommand();
                        //dAdapter.DeleteCommand = cBuilder.GetDeleteCommand();


                        //dAdapter.RowUpdating += DAdapter_RowUpdating;
                        dAdapter.Fill(dataSet, "tablename");
                        var e = new RowUpdatedEventArgs(dataSet.Tables[0].Rows[0], new SqlCommand(), StatementType.Batch, new DataTableMapping());

                        //sqlCmd.Transaction = transaction;
                        //var sqldatareader = sqlCmd.ExecuteReader();
                        //sqldatareader.Read();
                        //var l = sqldatareader[3];
                        //sqldatareader.Close();
                    }

                    //transaction.Commit();
                }

                connection.Close();
            }
        }