|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: |
private void Next_Button_Click(object sender, EventArgs e)
{
Progress_Bar.Visible = true;
Progress_Bar.Minimum = 0;
Progress_Bar.Maximum = 24;
Progress_Bar.Step = 1;
Progress_Bar.Value = 0;
timer1.Enabled = true;
//call the check server method to continue
if (Test_Server())
{
NewPage2 form = new NewPage2();
form.Show();
close_dialog = true;
this.Close();
}
Progress_Bar.Value = 24;
}
the test_server method is basically just calling this method in my static class
//Here is where I create my connection.
private static SqlConnection createConn()
{
//Here you have your connection string you can edit it here.
//need to check if we have a DSN or not.
//also need to add username and password
string mySqlConnectionString = buildConnString();
//If you wish to use SQL security, well just make your own connection string...
//I make sure I have declare what mySqlConnection stand for.
if (mySqlConnection == null) { mySqlConnection = new SqlConnection(); };
// Since i will be reusing the connection I will try this it the connection dose not exist.
if (mySqlConnection.ConnectionString == string.Empty || mySqlConnection.ConnectionString == null)
{
// I use a try catch statement cuz I use 2 set of arguments to connect to the database
try
{
//First I try with a pool of 5-40 and a connection time out of 4 seconds. then I open the connection.
mySqlConnection.ConnectionString = "Min Pool Size=5;Max Pool Size=40;Connect Timeout=4;" + mySqlConnectionString + ";";
mySqlConnection.Open();
}
catch (Exception)
{
try
{
//If it did not work i try not using the pool and I give it a 45 seconds timeout.
if (mySqlConnection.State != ConnectionState.Closed)
{
mySqlConnection.Close();
}
//changed the timeout from 40s to 20s as too long to wait.
mySqlConnection.ConnectionString = "Pooling=false;Connect Timeout=20;" + mySqlConnectionString + ";";
mySqlConnection.Open();
}
catch (Exception e)
{
CustomMessage customMessage = new CustomMessage();
//parse the exception to find out what went wrong and relay it back.
if (e.Message.Contains("Login failed for user"))
throw new CustomException.CustomException(SeverityLevel.Fatal, GlobalVars.Debuglog, e.InnerException, customMessage.GetString("Login"));
else if(e.Message.Contains("network-related"))
throw new CustomException.CustomException(SeverityLevel.Fatal, GlobalVars.Debuglog, e.InnerException, customMessage.GetString("DSN"));
else
throw new CustomException.CustomException(SeverityLevel.Fatal, GlobalVars.Debuglog, e.InnerException, customMessage.GetString("Unknown"));
}
}
return mySqlConnection;
}
//Here if the connection exsist and is open i try this.
if (mySqlConnection.State != ConnectionState.Open)
{
try
{
mySqlConnection.ConnectionString = "Min Pool Size=5;Max Pool Size=40;Connect Timeout=4;" + mySqlConnectionString + ";";
mySqlConnection.Open();
}
catch (Exception)
{
try
{
if (mySqlConnection.State != ConnectionState.Closed)
{
mySqlConnection.Close();
}
mySqlConnection.ConnectionString = "Pooling=false;Connect Timeout=45;" + mySqlConnectionString + ";";
mySqlConnection.Open();
}
catch (Exception e)
{
CustomMessage customMessage = new CustomMessage();
//parse the exception to find out what went wrong and relay it back.
if (e.Message.Contains("Login failed for user"))
throw new CustomException.CustomException(SeverityLevel.Fatal, GlobalVars.Debuglog, e.InnerException, customMessage.GetString("Login"));
else if (e.Message.Contains("network-related"))
throw new CustomException.CustomException(SeverityLevel.Fatal, GlobalVars.Debuglog, e.InnerException, customMessage.GetString("DSN"));
else
throw new CustomException.CustomException(SeverityLevel.Fatal, GlobalVars.Debuglog, e.InnerException, customMessage.GetString("Unknown"));
}
}
}
return mySqlConnection;
}
|
Advertisement
| Hall of Fame |