Hi Sophia
You can use System.Data.MySqlClient instead of System.Data.SqlClient
dll file is published by Oracle
MySqlConnection in place of SqlConnection
MySqlCommand in place of SqlCommand
etc
if you want to use database objects independent to db type, you can use the base class:
DbConnection conn = new DbConnection(connectionString);
conn.Open();
and other codes
but you should manage the connectionString with attention to db type. maybe below codes:
Code:
DbConnection GetConnection(){
string dbType = System.Configuration.ConfigurationSettings.AppSettings("dbType");
switch(dbType){
case "sql":
return new System.Data.SqlConnection(sqlConnectionString);
case "mysql":
return new System.Data.MySqlConnection(mySqlConnectionString);
}
return new DbConnection(defaultConnectionString);
}
// otherwhere
DbConnection conn = GetConnection();
DbCommand cmd = conn.GetCommand();
// other codes here
what's your idea Imar?