日期:2014-05-18 浏览次数:20464 次
/// <summary> /// 返回Command实例,并且设置Connection和CommandText /// </summary> /// <param name="DataBaseType"></param> /// <param name="sql"></param> /// <returns></returns> public static DbCommand CreateCommand(int DataBaseType, string sql) { DbCommand cm = null; switch (DataBaseType) { case 2: cm = new System.Data.OracleClient.OracleCommand(sql, (System.Data.OracleClient.OracleConnection)CreateConnection()); break; case 3: cm = new System.Data.OleDb.OleDbCommand(sql, (System.Data.OleDb.OleDbConnection)CreateConnection()); break; case 4: cm = new System.Data.Odbc.OdbcCommand(sql, (System.Data.Odbc.OdbcConnection)CreateConnection()); break; default: [color=#FF0000] cm = new System.Data.SqlClient.SqlCommand(sql, (System.Data.SqlClient.SqlConnection)CreateConnection()); break;[/color] } return cm; }