Database connection string-MySQL
ODBC DSN
// ODBC DSN Using system. Data. ODBC; Odbcconnection conn = new odbcconnection (); Conn. connectionstring = "DSN = dsnname;" + "Uid = username;" + "Pwd = secret ;"; Conn. open (); |
// ODBC -- myodbc driver -- local database
// ODBC -- myodbc driver -- local database Using system. Data. ODBC; Odbcconnection conn = new odbcconnection (); Conn. connectionstring = "Driver = {MySQL};" + "Server = localhost;" + "Option = 16834;" + "Database = databasename ;" Conn. open (); |
ODBC -- myodbc driver -- remote database
// ODBC -- myodbc driver -- remote database Using system. Data. ODBC; Odbcconnection conn = new odbcconnection (); Conn. connectionstring = "Driver = {MySQL};" + "Server = db.domain.com;" + "Option = 131072;" + "Port = 3306;" + "Stmt =;" + "Database = databasename;" + "Uid = username;" + "Pwd = secret ;" Conn. open (); |
ODBC -- MySQL ODBC 3.51 driver
// ODBC -- MySQL ODBC 3.51 driver Using system. Data. ODBC; Odbcconnection conn = new odbcconnection (); Conn. connectionstring = "Driver = {MySQL ODBC 3.51 driver};" + "Server = servername;" + "Option = 16834;" + "Port = 3306;" + "Stmt =;" + "Database = databasename;" + "Uid = username;" + "Pwd = secret ;" Conn. open (); // Or Using system. Data. ODBC; Odbcconnection conn = new odbcconnection (); Conn. connectionstring = "Driver = {MySQL ODBC 3.51 driver};" + "Server = servername;" + "Database = databasename;" + "User = urername;" + "Password = secret ;" Conn. open (); |
// Oledb
// Oledb Using system. Data. oledb; Oledbconnection conn = new oledbconnection (); Conn. connectionstring = "Provider = mysqlprov;" + "Data Source = servername;" + "User ID = username;" + "Password = secret ;" Conn. open (); |
. Net dataprovider from CoreLab
//. Net dataprovider from CoreLab Using CoreLab. MySQL; Mysqlconnection conn = new mysqlconnection (); Conn. connectionstring = "Host = servername;" + "Database = databasename;" + "Protocol = TCP;" + "Port = 3306;" + "Direct = true;" + "Compress = false;" + "Pooling = true;" + "Min pool size = 0;" + "Max pool size = 100;" + "Connection lifetime = 0;" + "User ID = username;" + "Password = secret;" + Conn. open (); |