Skip to content

Commit

Permalink
A Fix for the Previous Commit
Browse files Browse the repository at this point in the history
Signed-off-by: Saranga Athukorale <[email protected]>
  • Loading branch information
sathukorale committed Jan 25, 2016
1 parent 112d041 commit 1b649ea
Showing 1 changed file with 22 additions and 35 deletions.
57 changes: 22 additions & 35 deletions libDatabaseHelper/classes/sqlce/ConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,56 +63,43 @@ public override bool CheckConnectionString(string connectionString)
}
catch {}

var connectionCretead = CreateConnection(null, connectionString);
if (connectionCretead != null && connectionCretead.State == System.Data.ConnectionState.Open)
{
return true;
}
return false;
}

protected override DbConnection CreateConnection(Type t, string connectionString)
{
SqlCeConnection connection = null;
try
{
var connection = new SqlCeConnection(connectionString);
connection = new SqlCeConnection(connectionString);
connection.Open();
connection.Close();
}
catch (System.Data.SqlServerCe.SqlCeInvalidDatabaseFormatException)
{
try
{
var engine = new SqlCeEngine(connectionString);
engine.Upgrade();
}
catch (System.Exception ex)
{
Console.WriteLine("Attempt on Upgrading SQL CE Database Failed (Reason = \"" + ex.Message + "\")");
return false;
}

try
{
var connection = new SqlCeConnection(connectionString);
connection.Open();
connection.Close();
try
{
connection = new SqlCeConnection(connectionString);
connection.Open();
}
catch (System.Exception){}
}
catch (System.Exception)
catch (System.Exception ex)
{
return false;
Console.WriteLine("Attempt on Upgrading SQL CE Database Failed (Reason = \"" + ex.Message + "\")");
}
}
catch (Exception)
{
return false;
}
return true;
}

protected override DbConnection CreateConnection(Type t, string connectionString)
{
try
{
var connectionCreated = new SqlCeConnection(connectionString);
connectionCreated.Open();
return connectionCreated;
}
catch (Exception ex)
{
Console.WriteLine("Unable to connect with conenction string = \"" + connectionString + "\" due to : " + ex.Message);
return null;/*(frmConnectionStringSetter.ShowWindow(t, GetSupportedDatabaseType()) ? GetConnection() : null)*/ ;
}
catch (Exception) {}
return connection;
}

public void LoadConnectionData()
Expand Down

0 comments on commit 1b649ea

Please sign in to comment.