protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase) { string statement = "SELECT SERVERPROPERTY('productversion') AS [version], SERVERPROPERTY ('productlevel') AS [level], SERVERPROPERTY ('edition') AS [edition]"; DBDatabaseProperties props; System.Data.SqlClient.SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder(forDatabase.ConnectionString); string dbname = builder.InitialCatalog; if (string.IsNullOrEmpty(dbname)) { dbname = builder.DataSource; } TypedOperationCollection unsupported = new TypedOperationCollection(); this.FillNotSupported(unsupported); DBSchemaInformation info = DBSchemaInformation.CreateDefault(); TopType[] tops = new TopType[] { TopType.Count, TopType.Percent, TopType.Range }; bool caseSensitive = false; string level = "?"; string edition = "?"; Version version = new Version(1, 0); forDatabase.ExecuteRead(statement, reader => { if (reader.Read()) { level = reader["level"].ToString(); edition = reader["edition"].ToString(); version = new Version(reader["version"].ToString()); } }); props = new DBDatabaseProperties(dbname, "SQL Server", level, edition, "@{0}", version, SupportedSchemaOptions.All, caseSensitive, DBParameterLayout.Named, SUPPORTED_TYPES, tops, info, unsupported); props.TemporaryTableConstruct = ""; props.TemporaryTablePrefix = "#"; return(props); }
protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase) { TypedOperationCollection unsupported = new TypedOperationCollection(); this.FillNotSupported(unsupported); DBSchemaInformation info = DBSchemaInformation.CreateDefault(); TopType[] tops = new TopType[] { TopType.Count, TopType.Percent, TopType.Range }; bool caseSensitive = false; string level = "?"; string edition = "?"; string database = "?"; Version version = new Version(1, 0); string statement = "SELECT SERVERPROPERTY('productversion') AS [version], SERVERPROPERTY ('productlevel') AS [level], SERVERPROPERTY ('edition') AS [edition], DB_NAME() As [currentdatabase]"; forDatabase.ExecuteRead(statement, reader => { if (reader.Read()) { level = reader["level"].ToString(); edition = reader["edition"].ToString(); version = new Version(reader["version"].ToString()); database = reader["currentdatabase"].ToString(); } }); DBDatabaseProperties props = new DBDatabaseProperties(database, "SQL Server", level, edition, "?", version, SupportedSchemaOptions.All, caseSensitive, DBParameterLayout.Positional, SUPPORTED_TYPES, tops, info, unsupported); props.TemporaryTableConstruct = ""; props.TemporaryTablePrefix = "#"; return(props); }
protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase) { DBDatabaseProperties props = null; string vers; string edition = string.Empty; string db = this.GetDataSourceNameFromConnection(forDatabase, ';', '=', "Database"); string versionFunction = "SELECT VERSION()"; try { object value = forDatabase.ExecuteScalar(versionFunction, System.Data.CommandType.Text); vers = Convert.ToString(value); //format of the version is similar to '5.0.87-standard' if (string.IsNullOrEmpty(vers) == false) { int index = vers.IndexOf('-'); if (index > -1) { edition = vers.Substring(index + 1).Trim(); vers = vers.Substring(0, index - 1); } } TypedOperationCollection unsupported = new TypedOperationCollection(); props = new DBDatabaseProperties(db, "MySql", string.Empty, edition, "?{0}", new Version(vers), SupportedSchemaOptions.All, false, DBParameterLayout.Named, SUPPORTED_TYPES, SUPPORTED_TOPTYPES, DBSchemaInformation.CreateDefault(), unsupported ); } catch (Exception ex) { throw new System.Data.DataException(Errors.CannotGetPropertiesFromDB, ex); } return(props); }
protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase) { string con = forDatabase.ConnectionString; //looking for 'Provider=Microsoft.ACE.OLEDB.12.0;' int index = con.IndexOf("Provider="); string provider = string.Empty; if (index > -1) { provider = con.Substring(index + "Provider=".Length); index = provider.IndexOf(';'); if (index > 0) { provider = provider.Substring(0, index); } else { provider = string.Empty; } } DBDatabaseProperties props; if (!string.IsNullOrEmpty(provider)) { if (this.TryGetProviderSpecificProperties(provider, forDatabase, out props)) { return(props); } } TypedOperationCollection unsupported = new TypedOperationCollection(); this.FillNotSupported(unsupported); string datasource = GetDataSourceNameFromConnection(forDatabase, ';', '=', "data source"); props = new DBDatabaseProperties(datasource, "OleDb", "?", "?", "?{0}", new Version("0.0"), SupportedSchemaOptions.TablesViewsAndIndexes, false, DBParameterLayout.Positional, SUPPORTED_TYPES, new TopType[] { TopType.Count }, DBSchemaInformation.CreateDefault(), unsupported); return(props); }