From 9a6cdf662b60e7d6f6843826da6a84637d4798b9 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 15 Nov 2008 21:27:10 +0000 Subject: Mantis#2626: Thank you Ruud Lathrop, for a patch that cleans up MSSQL code. --- OpenSim/Data/MSSQL/MSSQLGridData.cs | 55 ++----------------------------------- 1 file changed, 2 insertions(+), 53 deletions(-) (limited to 'OpenSim/Data/MSSQL/MSSQLGridData.cs') diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs index ace3b27..80c7798 100644 --- a/OpenSim/Data/MSSQL/MSSQLGridData.cs +++ b/OpenSim/Data/MSSQL/MSSQLGridData.cs @@ -54,6 +54,7 @@ namespace OpenSim.Data.MSSQL #region IPlugin Members + [Obsolete("Cannot be default-initialized!")] override public void Initialise() { m_log.Info("[GRID DB]: " + Name + " cannot be default-initialized!"); @@ -67,7 +68,7 @@ namespace OpenSim.Data.MSSQL /// use mssql_connection.ini override public void Initialise(string connectionString) { - if (string.IsNullOrEmpty(connectionString)) + if (!string.IsNullOrEmpty(connectionString)) { database = new MSSQLManager(connectionString); } @@ -93,63 +94,11 @@ namespace OpenSim.Data.MSSQL settingPassword); } - //TODO this can be removed at a certain time - TestTables(); - //New migrations check of store database.CheckMigration(_migrationStore); } /// - /// Test is region - /// - private void TestTables() - { - using (AutoClosingSqlCommand cmd = database.Query("SELECT TOP 1 * FROM " + m_regionsTableName, new Dictionary())) - { - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception) - { - m_log.Info("[GRID DB]: MSSQL Database doesn't exist... creating"); - database.ExecuteResourceSql("Mssql-regions.sql"); - } - } - using (AutoClosingSqlCommand cmd = database.Query("select * from migrations where name = '" + _migrationStore + "'")) - { - //Special for Migrations to create backword compatible - try - { - bool insert = true; - using (SqlDataReader reader = cmd.ExecuteReader()) - { - if (reader.Read()) insert = false; - } - if (insert) - { - cmd.CommandText = "insert into migrations(name, version) values('" + _migrationStore + "', 1)"; - cmd.ExecuteNonQuery(); - } - } - catch - { - //No migrations table - //HACK create one and add data - cmd.CommandText = "create table migrations(name varchar(100), version int)"; - cmd.ExecuteNonQuery(); - - cmd.CommandText = "insert into migrations(name, version) values('migrations', 1)"; - cmd.ExecuteNonQuery(); - - cmd.CommandText = "insert into migrations(name, version) values('" + _migrationStore + "', 1)"; - cmd.ExecuteNonQuery(); - } - } - } - - /// /// Shuts down the grid interface /// override public void Dispose() -- cgit v1.1