Exemple #1
0
        /// <summary>
        /// Set the DataAdapter into this CommandBuilder.
        /// </summary>
        /// <param name="adapter"></param>
        protected override void SetRowUpdatingHandler(DbDataAdapter adapter)
        {
            IngresDataAdapter oldAdapter = this.DataAdapter as IngresDataAdapter;
            IngresDataAdapter newAdapter = adapter     as IngresDataAdapter;

            // remove old event handler (this.DataAdapter is in use)
            if (oldAdapter != null)
            {
                oldAdapter.RowUpdating -=
                    new IngresRowUpdatingEventHandler(this.RowUpdatingHandler);
                return;
            }

            // add new event handler (this.DataAdapter is not in use)
            if (newAdapter != null)
            {
                newAdapter.RowUpdating +=
                    new IngresRowUpdatingEventHandler(this.RowUpdatingHandler);
            }
        }          // SetRowUpdatingHandler
        public DataTable GetTable()
        {
            var dataTable = new DataTable();
            if (!DbEnabled)
                return dataTable;

            switch (DatabaseManager.DatabaseConnectionType.ToLower())
            {
                case "firebird":
                    try
                    {
                        using (var adapter = new FbDataAdapter(CommandFireBird))
                            adapter.Fill(dataTable);
                    }
                    catch (Exception exception)
                    {
                        Writer.Writer.LogQueryError(exception, CommandFireBird.CommandText);
                        throw exception;
                    }
                    break;

                case "ingres":
                case "ingress":
                    try
                    {
                        using (var adapter = new IngresDataAdapter(CommandIngress))
                            adapter.Fill(dataTable);
                    }
                    catch (Exception exception)
                    {
                        Writer.Writer.LogQueryError(exception, CommandIngress.CommandText);
                        throw exception;
                    }
                    break;

                case "pgsql":
                    try
                    {
                        using (var adapter = new NpgsqlDataAdapter(CommandPgSql))
                            adapter.Fill(dataTable);
                    }
                    catch (Exception exception)
                    {
                        Writer.Writer.LogQueryError(exception, CommandPgSql.CommandText);
                        throw exception;
                    }
                    break;

                default:
                    try
                    {
                        using (var adapter = new MySqlDataAdapter(CommandMySql))
                            adapter.Fill(dataTable);
                    }
                    catch (Exception exception)
                    {
                        Writer.Writer.LogQueryError(exception, CommandMySql.CommandText);
                        throw exception;
                    }
                    break;
            }
            return dataTable;
        }
        public DataRow GetRow()
        {
            if (!DbEnabled)
                return null;

            DataRow row = null;
            switch (DatabaseManager.DatabaseConnectionType.ToLower())
            {
                case "firebird":
                    try
                    {
                        var dataSet = new DataSet();
                        using (var adapter = new FbDataAdapter(CommandFireBird))
                            adapter.Fill(dataSet);
                        if ((dataSet.Tables.Count > 0) && (dataSet.Tables[0].Rows.Count == 1))
                            row = dataSet.Tables[0].Rows[0];
                    }
                    catch (Exception exception)
                    {
                        Writer.Writer.LogQueryError(exception, CommandFireBird.CommandText);
                        throw exception;
                    }
                    break;

                case "ingres":
                case "ingress":
                    try
                    {
                        var dataSet = new DataSet();
                        using (var adapter = new IngresDataAdapter(CommandIngress))
                            adapter.Fill(dataSet);
                        if ((dataSet.Tables.Count > 0) && (dataSet.Tables[0].Rows.Count == 1))
                            row = dataSet.Tables[0].Rows[0];
                    }
                    catch (Exception exception)
                    {
                        Writer.Writer.LogQueryError(exception, CommandIngress.CommandText);
                        throw exception;
                    }
                    break;

                case "pgsql":
                    try
                    {
                        var dataSet = new DataSet();
                        using (var adapter = new NpgsqlDataAdapter(CommandPgSql))
                            adapter.Fill(dataSet);
                        if ((dataSet.Tables.Count > 0) && (dataSet.Tables[0].Rows.Count == 1))
                            row = dataSet.Tables[0].Rows[0];
                    }
                    catch (Exception exception)
                    {
                        Writer.Writer.LogQueryError(exception, CommandPgSql.CommandText);
                        throw exception;
                    }
                    break;

                default:
                    try
                    {
                        var dataSet = new DataSet();
                        using (var adapter = new MySqlDataAdapter(CommandMySql))
                            adapter.Fill(dataSet);
                        if ((dataSet.Tables.Count > 0) && (dataSet.Tables[0].Rows.Count == 1))
                            row = dataSet.Tables[0].Rows[0];
                    }
                    catch (Exception exception)
                    {
                        Writer.Writer.LogQueryError(exception, CommandMySql.CommandText);
                        throw exception;
                    }
                    break;
            }            
            return row;
        }
Exemple #4
0
 /// <summary>
 /// Ingres implementatin of DbCommandBuilder to assist in
 /// automatically generating single-table commands for
 /// DataSet to database reconciliation.
 /// </summary>
 /// <param name="adapter"></param>
 public IngresCommandBuilder(IngresDataAdapter adapter)
     : this()
 {
     this.DataAdapter = adapter;
 }
Exemple #5
0
        // Name: CheckVersion - Test the stored schema version
        //
        // Description:
        //      Compares the specified version number with the stored version
        //      If the verson matches or exceeds the required version the
        //      function returns true.
        //
        // Inputs:
        //      Major       Major version number.
        //      Minor       Minor version number.
        //      Release     Release version number.
        //
        // Outputs:
        //      None.
        //
        // Returns:
        //      true        Version matches or exceeds the required version.
        //      false       Incorrect version level.
        //
        // History
        //      02-Oct-2006 ([email protected])
        //          Created.
        public bool CheckVersion(int Major, int Minor, int Release)
        {
            bool retcode = false;
            IngresCommand ingresVersionSelect = new IngresCommand();
            IngresDataAdapter ingresVersionAdapter;

            // Create query parameters and store the method parameter values
            // into each one.
            IngresParameter majorVersion = new IngresParameter("ver_major", IngresType.Int);
            IngresParameter minorVersion = new IngresParameter("ver_minor", IngresType.Int); ;
            IngresParameter releaseVersion = new IngresParameter("ver_release", IngresType.Int);

            majorVersion.Value = Major;
            minorVersion.Value = Minor;
            releaseVersion.Value = Release;

            ingresVersionSelect = new IngresCommand(
                "SELECT FIRST 1 ver_major, ver_minor, ver_release, ver_date, ver_install" +
                " FROM version" +
                " WHERE ver_major >= ? AND ver_minor >= ? AND ver_release >=?" +
                " ORDER BY ver_id DESC",
                ingresConnection1);
            ingresVersionSelect.Connection = ingresConnection1;
            ingresVersionAdapter = new IngresDataAdapter(ingresVersionSelect);
            try
            {
                ingresVersionSelect.Connection.Open();
                ingresVersionSelect.Prepare();
                ingresVersionSelect.Parameters.Clear();
                ingresVersionSelect.Parameters.Add(majorVersion);
                ingresVersionSelect.Parameters.Add(minorVersion);
                ingresVersionSelect.Parameters.Add(releaseVersion);
                versionDataSet.Clear();
                ingresVersionAdapter.Fill(versionDataSet);
                if (versionDataSet.Tables[0].Rows.Count > 0)
                {
                    retcode = true;
                }
            }
            catch (Ingres.Client.IngresException ex)
            {
                if (DisplayError(ex) == DialogResult.OK)
                {
                    throw;
                }
                else
                {
                    Application.Exit();
                }
            }
            finally
            {
                if (ingresVersionSelect != null &&
                    ingresVersionSelect.Connection != null)
                    ingresVersionSelect.Connection.Close();
            }
            return (retcode);
        }
Exemple #6
0
        private void InitializeIngres()
        {
            versionDataSet = new DataSet();

            // The following query text is used to show the syntax for
            // executing a database procedure.
            ingresSelectCommand4 = new IngresCommand(
                "{ call get_my_airports( ccode = ?, area = ? ) }",
                ingresConnection1);
            ingresSelectCommand4.Connection = ingresConnection1;
            ingresDataAdapter4 = new IngresDataAdapter(ingresSelectCommand4);

            ingresSelectCommand7 = new IngresCommand(
                "SELECT up_email FROM user_profile ORDER BY up_email");
            ingresSelectCommand7.Connection = ingresConnection1;
            ingresDataAdapter7 = new IngresDataAdapter(ingresSelectCommand7);

            ingresSelectCommand8 = new IngresCommand(
                "SELECT airport.ap_iatacode, airport.ap_place, " +
                    "country.ct_name " +
                "FROM airport, country " +
                "WHERE airport.ap_ccode = country.ct_code " +
                    "AND airport.ap_iatacode = ?");
            ingresSelectCommand8.Connection = ingresConnection1;
            ingresDataAdapter8 = new IngresDataAdapter(ingresSelectCommand8);

            if (CheckVersion() == false)
            {
                // Incorrect version exception.
                // Get the string from the string table
                Exception badVersion = new Exception(rm.GetString("ErrorVersion"));
                throw badVersion;
            }
        }
Exemple #7
0
 /// <summary>
 /// Ingres implementatin of DbCommandBuilder to assist in
 /// automatically generating single-table commands for
 /// DataSet to database reconciliation.
 /// </summary>
 /// <param name="adapter"></param>
 public IngresCommandBuilder(IngresDataAdapter adapter)
     : this()
 {
     this.DataAdapter = adapter;
 }
Exemple #8
0
 /// <summary>
 /// Create a new DataAdapter object from an old DataAdapter.
 /// </summary>
 /// <param name="oldAdapter">Old DataAdapter to clone from.</param>
 private IngresDataAdapter(IngresDataAdapter oldAdapter)
     : base(oldAdapter)
 {
 }
Exemple #9
0
        }  // end constructor DataAdapter

        /// <summary>
        /// Create a new DataAdapter object from an old DataAdapter.
        /// </summary>
        /// <param name="oldAdapter">Old DataAdapter to clone from.</param>
        private IngresDataAdapter(IngresDataAdapter oldAdapter) :
            base(oldAdapter)
        {
        }  // end constructor DataAdapter