public static DbTSQLInterface.DB_TSQL_INTERFACE_TYPE getTypeDB(string strConn) { DB_TSQL_INTERFACE_TYPE res = DB_TSQL_INTERFACE_TYPE.MSSQL; int port = -1; string strMarkPort = @"port=" , strPort = string.Empty; if (!(strConn.IndexOf(strMarkPort) < 0)) { int iPosPort = strConn.IndexOf(strMarkPort) + strMarkPort.Length; strPort = strConn.Substring(iPosPort, strConn.IndexOf(';', iPosPort) - iPosPort); if (Int32.TryParse(strPort, out port) == true) { res = getTypeDB(port); } else { ; } } else { ; } return(res); }
public DbTSQLInterface(DB_TSQL_INTERFACE_TYPE type, string name) : base(name) { m_connectionType = type; m_connectionSettings = new ConnectionSettings(); switch (m_connectionType) { case DB_TSQL_INTERFACE_TYPE.MySQL: m_dbConnection = new MySqlConnection(); m_dbCommand = new MySqlCommand(); m_dbCommand.Connection = m_dbConnection; m_dbCommand.CommandType = CommandType.Text; m_dbAdapter = new MySqlDataAdapter(); break; case DB_TSQL_INTERFACE_TYPE.MSSQL: m_dbConnection = new SqlConnection(); m_dbCommand = new SqlCommand(); m_dbCommand.Connection = m_dbConnection; m_dbCommand.CommandType = CommandType.Text; m_dbAdapter = new SqlDataAdapter(); break; case DB_TSQL_INTERFACE_TYPE.Oracle: m_dbConnection = new OracleConnection(); m_dbCommand = new OracleCommand(); m_dbCommand.Connection = m_dbConnection; m_dbCommand.CommandType = CommandType.Text; m_dbAdapter = new OracleDataAdapter(); break; case DB_TSQL_INTERFACE_TYPE.MSExcel: m_dbConnection = new OleDbConnection(); m_dbCommand = new OleDbCommand(); m_dbCommand.Connection = m_dbConnection; m_dbCommand.CommandType = CommandType.Text; m_dbAdapter = new OleDbDataAdapter(); break; default: break; } m_dbAdapter.SelectCommand = m_dbCommand; }