private BaseSyntaxProvider GetSyntaxProvider() { BaseSyntaxProvider sqlsyn = null; switch (this.DatabasePlatform) { case QueryBuilderDatabasePlatform.Oracle: sqlsyn = new OracleSyntaxProvider(); break; default: sqlsyn = new GenericSyntaxProvider(); break; } return(sqlsyn); }
private BaseSyntaxProvider GetSyntaxProvider() { BaseSyntaxProvider sqlsyn = null; switch (this.DatabasePlatform) { case QueryBuilderDatabasePlatform.MSSQLServer: sqlsyn = new MSSQLSyntaxProvider(); break; case QueryBuilderDatabasePlatform.SQLServerCE: //sqlsyn = new MSSQLCESyntaxProvider(); //does not work sqlsyn = new GenericSyntaxProvider(); //does not work break; case QueryBuilderDatabasePlatform.OLEDB: if (queryBuilder.MetadataProvider.Connection.ConnectionString.Contains("Provider=Microsoft.ACE.OLEDB.12.0") || queryBuilder.MetadataProvider.Connection.ConnectionString.Contains("Provider=Microsoft.Jet.OLEDB.4.0")) { sqlsyn = new MSAccessSyntaxProvider(); } else if (queryBuilder.MetadataProvider.Connection.ConnectionString.Contains("Provider=OraOLEDB.Oracle") || queryBuilder.MetadataProvider.Connection.ConnectionString.Contains("Provider=msdaora")) { sqlsyn = new OracleSyntaxProvider(); } else { switch (this.AnsiSQLVersion) { case AnsiSQLLevel.SQL89: sqlsyn = new SQL89SyntaxProvider(); break; case AnsiSQLLevel.SQL92: sqlsyn = new SQL92SyntaxProvider(); break; case AnsiSQLLevel.SQL2003: sqlsyn = new SQL2003SyntaxProvider(); break; } } break; case QueryBuilderDatabasePlatform.ODBC: if (queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("driver={microsoft access driver")) { sqlsyn = new MSAccessSyntaxProvider(); } else if (queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("driver={oracle") || queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("driver={microsoft odbc for oracle")) { sqlsyn = new OracleSyntaxProvider(); } else if (queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("driver={sql server") || queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("sql server")) { sqlsyn = new MSSQLSyntaxProvider(); } else if (queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("driver={ibm db2") || queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("ibm db2")) { sqlsyn = new DB2SyntaxProvider(); } else if (queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("driver={ibm informix") || queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("informix")) { sqlsyn = new InformixSyntaxProvider(); } else if (queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("driver={mysql")) { sqlsyn = new MySQLSyntaxProvider(); } else if (queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("driver={adaptive server") || queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("driver={sybase ase")) { sqlsyn = new SybaseSyntaxProvider(); } else if (queryBuilder.MetadataProvider.Connection.ConnectionString.ToLower().Contains("driver={sql anywhere")) { sqlsyn = new GenericSyntaxProvider(); } else { switch (this.AnsiSQLVersion) { case AnsiSQLLevel.SQL89: sqlsyn = new SQL89SyntaxProvider(); break; case AnsiSQLLevel.SQL92: sqlsyn = new SQL92SyntaxProvider(); break; case AnsiSQLLevel.SQL2003: sqlsyn = new SQL2003SyntaxProvider(); break; } } break; case QueryBuilderDatabasePlatform.MSAccess: sqlsyn = new MSAccessSyntaxProvider(); break; case QueryBuilderDatabasePlatform.Oracle: sqlsyn = new OracleSyntaxProvider(); break; default: sqlsyn = new GenericSyntaxProvider(); break; } return(sqlsyn); }
private void InitializeSqlContext() { try { Cursor = Cursors.WaitCursor; BaseMetadataProvider metadataProvider = null; BaseSyntaxProvider syntaxSyntaxProvider; // create new SqlConnection object using the connections string from the connection form if (!_selectedConnection.IsXmlFile) { syntaxSyntaxProvider = _selectedConnection.ConnectionDescriptor.SyntaxProvider; metadataProvider = _selectedConnection.ConnectionDescriptor.MetadataProvider; } else { switch (_selectedConnection.Type) { case ConnectionTypes.MSSQL: syntaxSyntaxProvider = new MSSQLSyntaxProvider(); break; case ConnectionTypes.MSAccess: syntaxSyntaxProvider = new MSAccessSyntaxProvider(); break; case ConnectionTypes.Oracle: syntaxSyntaxProvider = new OracleSyntaxProvider(); break; case ConnectionTypes.MySQL: syntaxSyntaxProvider = new MySQLSyntaxProvider(); break; case ConnectionTypes.PostgreSQL: syntaxSyntaxProvider = new PostgreSQLSyntaxProvider(); break; case ConnectionTypes.OLEDB: syntaxSyntaxProvider = new SQL92SyntaxProvider(); break; case ConnectionTypes.ODBC: syntaxSyntaxProvider = new SQL92SyntaxProvider(); break; default: throw new ArgumentOutOfRangeException(); } } // setup the query builder with metadata and syntax providers queryBuilder1.SQLContext.MetadataContainer.Clear(); queryBuilder1.MetadataProvider = metadataProvider; queryBuilder1.SyntaxProvider = syntaxSyntaxProvider; queryBuilder1.MetadataLoadingOptions.OfflineMode = metadataProvider == null; if (metadataProvider == null) { queryBuilder1.MetadataContainer.ImportFromXML(_selectedConnection.ConnectionString); } // Instruct the query builder to fill the database schema tree queryBuilder1.InitializeDatabaseSchemaTree(); toolStripStatusLabel1.Text = @"Query builder state: " + (queryBuilder1.SleepMode ? "Inactive" : "Active"); RepairImageLists(); RefreshNoConnectionLabel(); queryBuilder1.QueryView.UserPredefinedConditions.Clear(); queryBuilder1.QueryView.UserPredefinedConditions.Add( new PredefinedCondition( "Check range", null, "Between 10 AND 100", false)); } finally { Cursor = Cursors.Default; } }