c# - Protecting MySQL connection string -
c# - Protecting MySQL connection string -
i'm setting mysql connection c# application, i'm wondering if code offers kind of security against connection string hacks?, don't want expose connection credentials much them vulnerable.
protected mysqlconnection connection; protected string server; protected string database; protected string uid; protected string password; //initialize values private void initialize() { server = "localhost"; database = "databasename"; uid = "username"; password = "password"; var connectionstring = string.empty; connectionstring = "server=" + server + ";" + "database=" + database + ";" + "uid=" + uid + ";" + "password=" + password + ";"; connection = new mysqlconnection(connectionstring.tostring()); } //open connection database private bool openconnection() { seek { connection.open(); homecoming true; } grab (mysqlexception ex) { //when handling errors, can application's response based on error number. //the 2 mutual error numbers when connecting follows: //0: cannot connect server. //1045: invalid user name and/or password. switch (ex.number) { case 0: messagebox.show("cannot connect server. contact administrator"); break; case 1045: messagebox.show("invalid username/password, please seek again"); break; } homecoming false; } }
thanks.
c# mysql
Comments
Post a Comment