コード例 #1
0
        /// <summary>
        /// Creates and initializes a new instance of the QueryBuilder object.
        /// </summary>
        /// <returns>Returns instance of the QueryBuilder object.</returns>
        private QueryBuilder CreateQueryBuilder()
        {
            // Define connection string here
            //var connectionString = @"Driver={SQL Server};Server=(local);Uid=User;Pwd=Passw0rd;Database=Northwind;";
            var connectionString = "";

            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ApplicationException("Connection string is not set");
            }

            // Create an instance of the QueryBuilder object
            var queryBuilder = _aqbs.Create(instanceId);

            queryBuilder.SyntaxProvider = new AutoSyntaxProvider();

            // Turn this property on to suppress parsing error messages when user types non-SELECT statements in the text editor.
            queryBuilder.BehaviorOptions.AllowSleepMode = false;

            #region ODBC
            // Bind Active Query Builder to a live database connection.
            //queryBuilder.MetadataProvider = new ODBCMetadataProvider
            //{
            //    // Assign an instance of DBConnection object to the Connection property.
            //    Connection = DataBaseHelper.CreateOdbcConnection(connectionString)
            //};
            #endregion

            #region OleDb
            // Bind Active Query Builder to a live database connection.
            queryBuilder.MetadataProvider = new OLEDBMetadataProvider
            {
                // Assign an instance of DBConnection object to the Connection property.
                Connection = DataBaseHelper.CreateMSAccessConnection("NorthwindDataBase")
            };
            #endregion



            //Comment these 2 lines for using browser localStorage
            ImportUserQueriesFromFile(queryBuilder.UserQueries);
            queryBuilder.UserQueries.Changed += ExportUserQueriesToFile;

            // Assign the initial SQL query text the user sees on the _first_ page load
            //queryBuilder.SQL = GetDefaultSql();

            return(queryBuilder);
        }
        /// <summary>
        /// Initializes a new instance of the QueryBuilder object.
        /// </summary>
        /// <param name="queryBuilder">Active Query Builder instance.</param>
        private void InitializeQueryBuilder(QueryBuilder queryBuilder)
        {
            queryBuilder.SyntaxProvider = new MSAccessSyntaxProvider();

            // Turn this property on to suppress parsing error messages when user types non-SELECT statements in the text editor.
            queryBuilder.BehaviorOptions.AllowSleepMode = false;

            // Bind Active Query Builder to a live database connection.
            queryBuilder.MetadataProvider = new OLEDBMetadataProvider
            {
                // Assign an instance of DBConnection object to the Connection property.
                Connection = DataBaseHelper.CreateMSAccessConnection("NorthwindDataBase")
            };

            // Assign the initial SQL query text the user sees on the _first_ page load
            queryBuilder.SQL = GetDefaultSql();
        }
コード例 #3
0
        /// <summary>
        /// Creates and initializes a new instance of the QueryBuilder object.
        /// </summary>
        /// <param name="AInstanceId">String which uniquely identifies an instance of Active Query Builder in the session.</param>
        /// <returns>Returns instance of the QueryBuilder object.</returns>
        private QueryBuilder CreateQueryBuilder(string AInstanceId)
        {
            // Create an instance of the QueryBuilder object
            var queryBuilder = QueryBuilderStore.Factory.MSAccess(AInstanceId);

            // Turn this property on to suppress parsing error messages when user types non-SELECT statements in the text editor.
            queryBuilder.BehaviorOptions.AllowSleepMode = false;

            // Bind Active Query Builder to a live database connection.
            queryBuilder.MetadataProvider = new OLEDBMetadataProvider
            {
                // Assign an instance of DBConnection object to the Connection property.
                Connection = DataBaseHelper.CreateMSAccessConnection("NorthwindDataBase")
            };

            // Assign the initial SQL query text the user sees on the _first_ page load
            //queryBuilder.SQL = GetDefaultSql();

            return(queryBuilder);
        }