I decided that this forum doesn't deserve or appreciate my work and I am not going to support it by releasing/maintaining my work and generating traffic for it.
public Update Set(string column, object value)
{
UpdateString += column + "='" + value + "', ";
return this;
}
public Update Where(string column, object value)
{
UpdateString = UpdateString.Remove(UpdateString.Length - 2, 2);
UpdateString += " WHERE " + column + "='" + value + "'";
return this;
}
public void Set(string column, object value)
{
UpdateString += column + "='" + value + "', ";
}
public void Where(string column, object value)
{
UpdateString = UpdateString.Remove(UpdateString.Length - 2, 2);
UpdateString += " WHERE " + column + "='" + value + "'";
}
im aware of that but with out the return; any update command it'll look something like .Quote:
You got these:
Where you could just do:
Why?
Because there is no point returning something, that is already there.
//with return; will look like
SQL.Engine.Update("Table")
.Set("column", "value")
.Where("column", "value")
.Execute();
//with out the return;
SQL.Engine.Update("Table").Set("column", "value");
SQL.Engine.Update("Table").Where("column", "value");
SQL.Engine.Update("Table").Execute();
//and each time you do
SQL.Engine.Update("Table").etc
//a new update command well be created .
A good pooling system (already done by the mysql dev team) beside what Korvacs said and your mysql will rock. Don't limit yourself to one connection which may fail. All you have to do is study a bit about mysql's connection bug and connection string.Quote:
Stored procedures, cached lookup, settings on the sql server etc.
i am on it .Quote:
Stored procedures, cached lookup, settings on the sql server etc.
thanks impulse :)Quote:
A good pooling system (already done by the mysql dev team) beside what Korvacs said and your mysql will rock. Don't limit yourself to one connection which may fail. All you have to do is study a bit about mysql's connection bug and connection string.
if (connected.Died)
{
connected = GetNewConnectionFromSomewhere
AddConnection to somewhere.
}
using(MySqlConnection conn = new MySqlConnection(...)) {
conn.Open();
using(MySqlCommand cmd = new MySqlCommand(QUERY, conn))
{
cmd.ExecuteNonQuery();
}
}
Quote:
Have a few connections should one die, pull another, add a new connection.
public class Engine
{
private static MySqlConnection connection;
private static EventHandler ConnectionWatcher = new EventHandler(RestartConnection);
public Engine(MySqlConnection Connection)
{
connection = Connection;
connection.Disposed += ConnectionWatcher;
}
private static void RestartConnection(Object sender, EventArgs e)
{
try
{
connection.Open();
connection.Disposed += ConnectionWatcher;
//Console.WriteLine(" ConnectionState: Connection has been closed but it's been reconnected Successfully");
}
catch { }
}
}
Quote:
Ok, in case you didn't read this post, read it [Only registered and activated users can see links. Click Here To Register...]
^ last paragraph (the EDIT).
As long as you don't set the connection property 'pooling=false' you should dispose of your sql objects. Example:
public void Execute()
{
try
{
Query = "UPDATE " + table + " SET " + UpdateString;
OpenConnection(connection);// to make sure that the connection is opened
using (MySqlCommand cmd = new MySqlCommand(Query, connection))
{
cmd.ExecuteNonQuery();
}
}
catch (Exception X) { Console.WriteLine(X.Message); }
}
private void OpenConnection()
{
try
{
connection.Open();
}
catch {/*no need to catch any Exception as the Exception messag would be (already connected )*/ }
}
5 as max? well i guess its not my choice to make you have seen how the connection is being done and its being done the right way and when i said as max its been like (3 to 7 ms) but i have seen 10's .Quote:
10 milli sec's max? Oh dear, that doesnt sound good. If I was using mysql i'd be unhappy with that, mmm 5 max? Try have the connection param's already done. Maybe you could connect it and if they support a pause? Connect it, pause it, resume(which should really take a few ms) it and use it. But then again, im not a fanboy with mysql.
as for your question, Thats just it, personally if I was being tied up and slapped by a dick and had to use MySQL id have a list of waiting to execute querys. But that's why mysql isnt good, check out binary(hybrids SAFE binary class) or ini. They're both very good and binary is by FAAAR better then mysql. but if you like the style then mssql is always there.
just in case you dident see the ( connection = new MySqlConnection(ConString); ) part . im not creating a new connection with new passed param's every time i reconnect it . all it takes is (connection.open();)Quote:
public SqlEngine(string Host, string DataBase, string UserName, string Password)
{
string ConString = "SERVER=" + Host + ";" + "Persist Security Info=yes; Max Pool Size=25; Min Pool Size=5;" + "DATABASE=" + DataBase + ";" + "UID=" + UserName + ";" + "PASSWORD=" + Password + ";";
connection = new MySqlConnection(ConString);
}
so basically there is nothing wrong with the way its reconnecting .Quote:
Connection pooling works by keeping the native connection to the server live when the client disposes of a MySqlConnection. Subsequently, if a new MySqlConnection object is opened, it will be created from the connection pool, rather than creating a new native connection. This improves performance.
To work as designed, it is best to let the connection pooling system manage all connections. You should not create a globally accessible instance of MySqlConnection and then manually open and close it. This interferes with the way the pooling works and can lead to unpredictable results or even exceptions.