//---------------------------------------------------------------------------------------------------- /// <summary> /// 테이블 읽기 /// </summary> /// <param name="table">테이블 객체</param> /// <param name="sql">SQL문</param> /// <returns>데이터어답터 객체</returns> //---------------------------------------------------------------------------------------------------- public DbDataAdapter ReadTable( DataTable table, string sql ) { if( !Connect() ) return null; DbDataAdapter adapter=null; try { // Select 커멘더 생성 m_command = m_connection.CreateCommand(); m_command.CommandType = CommandType.Text; m_command.CommandText = sql; // 어답터 생성 switch(m_type) { case eType.SQLite: adapter = new SqliteDataAdapter((SqliteCommand)m_command); break; case eType.MySQL: adapter = new MySqlDataAdapter((MySqlCommand)m_command); break; case eType.MSSQL: adapter = new SqlDataAdapter((SqlCommand)m_command); break; case eType.Oracle: adapter = new OracleDataAdapter((OracleCommand)m_command); break; } // Insert,Update,Delete 컴멘더 생성 DbCommandBuilder builder = null; switch(m_type) { case eType.SQLite: builder = new SqliteCommandBuilder(); break; case eType.MySQL: builder = new MySqlCommandBuilder(); break; case eType.MSSQL: builder = new SqlCommandBuilder(); break; case eType.Oracle: builder = new OracleCommandBuilder(); break; } builder.DataAdapter = adapter; adapter.InsertCommand = builder.GetInsertCommand(); adapter.UpdateCommand = builder.GetUpdateCommand(); adapter.DeleteCommand = builder.GetDeleteCommand(); // 테이블 채워 넣기 adapter.Fill(table); return adapter; } catch( Exception ex ) { Log( ex.ToString() ); m_error = ex.Message; CloseQuery(); return null; } }
//---------------------------------------------------------------------------------------------------- /// <summary> /// 아답터 생성 /// </summary> /// <param name="table_name">테이블 이름</param> /// <returns>데이터어답터 객체</returns> //---------------------------------------------------------------------------------------------------- public DbDataAdapter CreateAdapter( string table_name ) { if( !Connect() ) return null; // Select 커멘더 생성 DbCommand command = m_connection.CreateCommand(); command.CommandType = CommandType.Text; command.CommandText = "SELECT * FROM " + table_name; // 어답터 생성 DbDataAdapter adapter=null; switch(m_type) { case eType.SQLite: adapter = new SqliteDataAdapter((SqliteCommand)command); break; case eType.MySQL: adapter = new MySqlDataAdapter((MySqlCommand)command); break; case eType.MSSQL: adapter = new SqlDataAdapter((SqlCommand)command); break; case eType.Oracle: adapter = new OracleDataAdapter((OracleCommand)command); break; } // Insert,Update,Delete 컴멘더 생성 DbCommandBuilder builder = null; switch(m_type) { case eType.SQLite: builder = new SqliteCommandBuilder(); break; case eType.MySQL: builder = new MySqlCommandBuilder(); break; case eType.MSSQL: builder = new SqlCommandBuilder(); break; case eType.Oracle: builder = new OracleCommandBuilder(); break; } builder.DataAdapter = adapter; adapter.InsertCommand = builder.GetInsertCommand(); adapter.UpdateCommand = builder.GetUpdateCommand(); adapter.DeleteCommand = builder.GetDeleteCommand(); return adapter; }