Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

ADOThe .NET 드라이버 일부 기능을 지원하는 .NET (C#) Connector 라이브러리를 제공하고 있다. 라이브러리 위치는 (C #) Connector library that supports some features of the ADO.NET driver is provided. 

The library location is  $MACHBASE_HOME/lib/ 에서 DLL 형태로 제공하고 있으며, .NET 버전에 따라 다른 DLL 을 제공한다 provided as a DLL type. It provides different DLLs depending on the .NET version.

  • > .NET Framework 4.0: machNetConnector.dll
  • > .NET Core 2.0: machNetConnectorCore.dll
클래스

Class


MachConnection : DbConnection
Info

아래 소개된 기능 외의 것은 아직 구현되어 있지 않거나, 올바르게 작동되지 않을 수 있다.
미구현으로 명시된 메서드나 필드를 부르는 경우, NotImplementedException 또는 NotSupportedException 을 발생시킨다.

마크베이스와의 연결을 담당하는 클래스이다. DbConnection 과 같이 IDisposable 을 상속받기 때문에, Dispose() 를 통한 객체 해제나 using() 문을 이용한 객체의 자동 Dispose를 지원한다.

Features not listed below may not be implemented yet or may not work correctly. 

If you call a method or field that is not a named instance, it generates NotImplementedException or a NotSupportedException.

MachConnection : DbConnection


This class is responsible for linking with Machbase. Because it inherits IDisposable like DbConnection, it supports disassociation through Dispose () or automatic disposition of object using using () statement.

생성자설명
MachConnection(string aConnectionString)Creates a MachConnection with a Connection String 을 입력으로, MachConnection 을 생성한다as input.


메서드설명
Open()입력받은 Connection String 으로 실제 연결을 시도한다Attempts to connect to the connection string.
Close()연결 중이라면, 해당 연결을 종료한다Closes the connection when connecting.
BeginDbTransaction(IsolationLevel isolationLevel)(미구현) MACHBASE 는 특별한 Transaction 이 없으므로 해당 객체 역시 지원하지 않는다Not yet implemented) MACHBASE does not support this object because there is no special transaction.
CreateDbCommand()(미구현) 아직은, 명시적으로 MachCommand 를 만들도록 유도한다.Not yet implemented) Explicitly induces MachCommands to be created
ChangeDatabase(string databaseName)

(미구현Not yet implemented) MACHBASE has no DATABASE 구분이 없다classification.


목차


Table of Contents
maxLevel3
indent20px
exclude목차
classtoc


필드설명
StateRepresents a System.Data.ConnectionState 값을 나타낸다value.
StatusString연결된 MachCommand 로 수행하는 상태를 나타낸다.
Error Message 를 꾸미는 용도로 내부에서 사용되며, 작업이 시작된 상태를 나타내기 때문에 이 값으로 쿼리 상태를 체크하는 것은
적절하지 않다

Indicates the state to be performed by the connected MachCommand. 

This is used internally to decorate the Error Message and it is not appropriate to check the status of the query with this value because it indicates the state in which the operation started.

Database(미구현Not yet implemented)
DataSource(미구현Not yet implemented)
ServerVersion(미구현Not yet implemented)



Info

Connection String

각 항목은 Each item is separated by a semicolon (;) 으로 구분되며, 다음을 사용할 수 있다.
동일 항목에 있는 여러 Keyword 는, 모두 같은 의미이다 

Many of the keywords in the same section have the same meaning.


Keyword설명예제기본값Default value

DSN
SERVER
HOST

HostnameDSN=localhost
SERVER=192.168.0.1

PORT
PORT_NO
Port No.PORT=56565656
USERID
USERNAME
USER
UID
사용자 User IDUSER=SYSSYS
PASSWORD
PWD
사용자 패스워드User passwordPWD=manager
CONNECT_TIMEOUT
ConnectionTimeout
connectTimeout
연결 최대 시간Maximum connection timeCONNECT_TIMEOUT60초60 second
COMMAND_TIMEOUT
commandTimeout
명령 수행 최대 시간Maximum time to perform each commandCOMMAND_TIMEOUT60초
예제로, 아래와 같은 문자열을 준비해 둘 수 있다
60 second

As an example, we can prepare the following string.

Code Block
languagec#
String sConnString = String.Format("DSN={0};PORT_NO={1};UID=;PWD=MANAGER;CONNECT_TIMEOUT=10000;COMMAND_TIMEOUT=50000", SERVER_HOST, SERVER_PORT);



MachCommand : DbCommand

MachConnection 을 이용해 SQL 명령 또는 APPEND 를 수행하는 클래스이다.
DbCommand 와 같이 IDisposable 을 상속받기 때문에, Dispose() 를 통한 객체 해제나 using() 문을 이용한 객체의 자동 Dispose를 지원한다.A class that performs SQL commands or APPEND using MachConnection . 
Since it inherits IDisposable like DbCommand, it supports object disposal through Dispose () or automatic disposal of object using using () statement

생성자설명
MachCommand(string aQueryString, MachConnection)연결할 MachConnection 객체와 함께, 수행할 쿼리를 입력해서 생성한다Creates by typing the query to be executed along with the MachConnection object to be connected.
MachCommand(MachConnection)연결할 MachConnection 객체를 입력해서 생성한다. 수행할 쿼리가 없는 경우 (e.g. APPEND) 에만 사용한다Creates a MachConnection object to connect to. Use only if there is no query to perform (eg APPEND).


ulong 객체로 시간 값을 표현할 때, 단순히 DateTime 객체의 Tick 값을 입력하면 안 된다.
그 값에서, 1970-01-01 을 나타내는 DateTime Tick 값을 제외한 값을 입력해야 한다

object, it takes a list containing the data and enters it into the database.

  • In the order of the data in the List, each datatype must match the datatype of the column represented in the table.
  • If the data in the List is insufficient or overflows, an error occurs.

메서드설명
void CreateParameter() /
void CreateDbParameter()
새로운 Creates a new MachParameter 를 생성한다.
void Cancel()(미구현Not yet implemented)
void Prepare()(미구현Not yet implemented)
MachAppendWriter
AppendOpen(aTableName, aErrorCheckCount = 0, MachAppendOption = None)

Starts APPEND 를 시작한다. Returns a MachAppendWriter 객체를 반환한다object.

  • aTableName:
대상 테이블 이름
  • Target table name
  • aErrorCheckCount: Each time the cumulative number of records entered by APPEND-DATA
로 입력한 레코드 누적 개수가 일치할 때 마다, 서버로 보내 실패 여부를 확인한다.
말하자면, 자동 APPEND-FLUSH 지점을 정하는 셈이다.MachAppendOption : 현재는 하나의 옵션만 제공하고 있다
  • matches, it is checked whether it is sent to the server or not. 
    In other words, you are setting the automatic APPEND-FLUSH point.
  • MachAppendOption: Currently only one option is provided.
    • MachAppendOption.None:
아무런 옵션도 붙지 않는다
    • No options are attached.
    • MachAppendOption. MicroSecTruncated:
DateTime 객체의 값 입력 시, microsecond 까지만 표현된 값을 입력한다.
(DateTime 객체의 Ticks 값은 100 nanosecond 까지 표현된다
    • When inputting the value of a DateTime object, enter the value expressed only up to microsecond. 
      (The Ticks value of a DateTime object is expressed up to 100 nanoseconds.)
void
AppendData(MachAppendWriter aWriter, List<object> aDataList)

Through the MachAppendWriter 객체를 통해, 데이터가 들어있는 리스트를 받아 데이터베이스에 입력한다.

  • List 에 들어간 데이터 순서대로, 각각의 자료형은 테이블에 표현된 컬럼의 자료형과 일치해야 한다.
  • List 에 들어있는 데이터가 모자라거나 넘치면, 에러를 발생시킨다.
Ui text box
typewarning
Warning

When representing a time value with a ulong object, simply do not enter the Tick value of the DateTime object. 

In that value, you must enter a value that excludes the DateTime Tick value that represents 1970-01-01 .


void
AppendDataWithTime(MachAppendWriter aWriter, List<object> aDataList, DateTime aArrivalTime)AppendData() 에서, Method that explicitly puts an _arrival_time 값을 DateTime 객체로 명시적으로 넣을 수 있는 메서드이다value into a DateTime object in AppendData().void
AppendDataWithTime(MachAppendWriter aWriter, List<object> aDataList, ulong aArrivalTimeLong)

AppendData() 에서, Method that can explicitly put _arrival_time 값을 ulong 객체로 명시적으로 넣을 수 있는 메서드이다.ulong 값을 _arrival_time 값으로 입력할 때 발생할 수 있는 문제는 위의 AppendData() 를 참고한다value into a ulong object in AppendData().

Refer to AppendData () above for problems that may occur when typing a ulong value as an _arrival_time value .

void AppendFlush(MachAppendWriter aWriter)

The data entered by AppendData () 로 입력한 데이터들을 즉시 서버로 보내, 데이터 입력을 강제한다.호출 빈도가 잦을 수록, 성능은 떨어지지만 시스템 오류로 인한 데이터 유실율을 낮출 수 있고 에러 검사를 빠르게 할 수 있다.
호출 빈도가 뜸할 수록, 데이터 유실이 발생할 가능성이 크고 에러 검사가 지연되지만 성능은 크게 올라간다is immediately sent to the server to force data insert.

The more frequently the call is made, the lower the data loss rate due to the system error and the faster the error check, although the performance is lowered. 
The less frequently the call is made, the more likely the data loss will occur and the error checking will be delayed, but the performance will increase significantly.

void AppendClose(MachAppendWriter aWriter)Closes APPEND 를 마친다. 내부적으로 Internally, after calling AppendFlush() 를 호출한 뒤에 실제 프로토콜을 마친다, the actual protocol is internally finished.int ExecuteNonQuery()

입력받았던 쿼리를 수행한다. 쿼리가 영향을 미친 레코드 개수를 반환한다.

보통 SELECT 를 제외한 쿼리를 수행할 때 사용한다Performs the input query. Returns the number of records affected by the query.

It is usually used when performing queries except SELECT.

object ExecuteScalar()

입력받았던 쿼리를 수행한다. 쿼리 Targetlist 의 첫 번째 값을 객체로 반환한다.

보통 SELECT 쿼리, 그 중에서도 결과가 1건만 나오는 SELECT (Scalar Query) 를 수행해 DbDataReader 없이 결과를 받고자 하는 경우 사용한다.Performs the input query. Returns the first value of the query targetlist as an object.

It is usually used when you want to perform a SELECT query, especially a SELECT (Scalar Query) with only one result, and get the result without a DbDataReader

DbDataReader ExecuteDbDataReader(CommandBehavior aBehavior)

입력받았던 쿼리를 수행해, 해당 쿼리의 결과를 읽어 올 수 있는 DbDataReader 를 생성해 반환한다Executes the input query, generates a DbDataReader that can read the result of the query, and returns it.


필드설명
Connection /
DbConnection
연결된 Connected MachConnection.
ParameterCollection /
DbParameterCollection
Binding 목적으로 사용할 MachParameterCollectionThe MachParameterCollection to use for the Binding purpose.
CommandText쿼리 문자열Query string.
CommandTimeout

특정 작업 수행 중, 서버로부터 응답을 기다리기까지의 시간.

MachConnection 에 설정된 값을 따르며, 여기서는 값 참조만 할 수 있다.

FetchSize

한번에 서버로부터 Fetch 할 레코드 개수. 기본값은 3000 이다.

IsAppendOpenedAPPEND 작업 중인 경우, Append 가 이미 열려있는지 아닌지를 판단한다.
CommandType(미구현)
DesignTimeVisible(미구현)
UpdatedRowSource(미구현)

MachDataReader : DbDataReader

Fetch 한 결과를 읽어들이는 클래스이다. 명시적으로 생성이 불가능하고 MachCommand.ExecuteDbDataReader() 로 생성된 객체만 사용이 가능하다

The amount of time it takes to perform a particular task, waiting for a response from the server.

It follows the values ​​set in MachConnection, where you can only reference values.

FetchSize

The number of records to fetch from the server at one time . The default value is 3000.

IsAppendOpenedDetermines if Append is already open when APPEND is at work
CommandType(Not yet implemented)
DesignTimeVisible(Not yet implemented)
UpdatedRowSource(Not yet implemented)


MachDataReader : DbDataReader

This is a class that reads fetch results. Only objects created with MachCommand.ExecuteDbDataReader () that can not be explicitly created are available.

메서드설명
string GetName(int ordinal)ordinal 번째 컬럼 이름을 반환한다Returns the ordinal column name.
string GetDataTypeName(int ordinal)ordinal 번째 컬럼의 자료형 이름을 반환한다Returns the datatype name of the ordinal column.
Type GetFieldType(int ordinal)ordinal 번째 컬럼의 자료형을 반환한다Returns the datatype of the ordinal column.
int GetOrdinal(string name)컬럼 이름이 위치한 인덱스를 반환한다Returns the index at which the column name is located.
object GetValue(int ordinal)현재 위치한 레코드의 ordinal 번째 값을 반환한다Returns the ordinal value of the current record.
bool IsDBNull(int ordinal)현재 위치한 레코드의 ordinal 번째 값이 NULL 인지 여부를 반환한다Returns whether the ordinal value of the current record is NULL.
int GetValues(object[] values)현재 위치한 레코드의 모든 값들을 전부 설정하고, 그 개수를 반환한다Sets all the values ​​of the current record and returns the number.
xxxx GetXXXX(int ordinal)

ordinal 번째 컬럼 값을, 자료형 Returns the ordinal column value according to the datatype (XXXX) 에 맞춰 반환한다.

  • Boolean
  • Byte
  • Char
  • Int16 / 32/64
  • DateTime
  • String
  • Decimal
  • Double
  • Float
bool Read()다음 레코드를 읽는다. 결과가 존재하지 않으면 False 를 반환한다Reads the next record. Returns False if the result does not exist.
DataTable GetSchemaTable()(미지원Not supported)
bool NextResult()(미지원Not supported)


필드설명
FetchSize한번에 서버로부터 Fetch 할 레코드 개수. 기본값은 3000 이며 여기서는 수정할 수 없다The number of records to fetch from the server at one time. The default is 3000, which can not be modified here.
FieldCount결과 컬럼 개수Number of result columns.
this[int ordinal]Equivalent to object GetValue (int ordinal) 와 동일하다.
this[string name]object Equivalent to object GetValue(GetOrdinal(name)) 와 동일하다.
HasRows결과가 존재하는지 여부를 나타낸다Indicates whether the result is present.
RecordsAffectedUnlike MachCommand 의 것과 달리, 여기서는 , here, it represents Fetch Count 를 나타낸다.


MachParameterCollection : DbParameterCollection

MachCommand 에 필요한 파라메터를 바인딩하는 클래스이다.

바인딩한 이후에 수행하게 되면, 해당 값이 같이 수행된다This is a class that binds parameters needed by MachCommand.

If you do this after binding, the values ​​are done together


Info

Since the concept of Prepared Statement 개념이 구현되어 있지 않아, Binding 이후 Execute 를 해도 수행 성능은 최초 수행한 것과 같다is not implemented, execution performance after Binding is the same as the performance performed first.


메서드설명
MachParameter
Add(string parameterName, DbType dbType)
파라메터 이름과 타입을 지정해, MachParameter 를 추가한다.
추가된 MachParameter 객체를 반환한다

Adds the MachParameter, specifying the parameter name and type. 

Returns the added MachParameter object.

int Add(object value)값을 추가한다. 추가된 인덱스를 반환한다Adds a value. Returns the index added.
void AddRange(Array values)단순 값의 배열을 모두 추가한다Adds an array of simple values.
MachParameter
AddWithValue(string parameterName, object value)
파라메터 이름과 그 값을 추가한다.
추가된 MachParameter 객체를 반환한다

Adds the parameter name and its value. 

Returns the added MachParameter object.

bool Contains(object value)해당 값이 추가되었는지 여부를 판단한다Determines whether or not the corresponding value is added.
bool Contains(string value)해당 파라메터 이름이 추가되었는지 여부를 판단한다Determines whether or not the corresponding parameter name is added.
void Clear()파라메터들을 모두 삭제한다Deletes all parameters.
int IndexOf(object value)해당 값의 인덱스를 반환한다Returns the index of the corresponding value.
int IndexOf(string parameterName)해당 파라메터 이름의 인덱스를 반환한다Returns the index of the corresponding parameter name.
void Insert(int index, object value)특정 인덱스에, 해당 값을 추가한다Adds the value to a specific index.
void Remove(object value)해당 값을 포함한 파라메터를 삭제한다Deletes the parameter including the value.
void RemoveAt(int index)인덱스에 위치한 파라메터를 삭제한다Deletes the parameter located at the index.
void RemoveAt(string parameterName)해당 이름을 가진 파라메터를 삭제한다Deletes the parameter with that name.



필드

Field

설명

Description

Count
파라메터 개수

Number of parameters

this[int index]
index 번째의 MachParameter 를 나타낸다

Indicates the MachParameter at index.

this[string name]

파라메터 이름과 일치하는 순서의 MachParameter 를 나타낸다

Indicates the MachParameter of the order in which the parameter names match.

MachParameter : DbParameter

MachCommand 에 필요한 파라메터를 각각 바인딩한 정보를 담는 클래스이다.

특별히 메서드는 지원하지 않는다.

필드설명ParameterName파라메터 이름ValueSize값의 크기

This is a class that contains the information that binds the necessary parameters to each MachCommand.

No special methods are supported.

Field

Description

ParameterName

Parameter name

Value

Value

Size

Value size

Direction

ParameterDirection (Input / Output / InputOutput / ReturnValue)

기본값은

The default value is Input

이다

.

DbTypeDB Type
MachDbType

MACHBASE DB Type

May differ from DB Type

과 다를 수 있다

.

IsNullable
NULL 가능 여부

Whether nullable

HasSetDbType

Whether DB Type

이 지정되었는지 여부

is specified

MachException : DbException

마크베이스에서 나타나는 에러를 표시하는 클래스이다.

에러 메시지가 설정되어 있는데, 모든 에러 메시지는 MachErrorMsg 에서 확인할 수 있다This is a class that displays errors that appear in Machbase.

An error message is set, and all error messages  can be found in  MachErrorMsg .


필드설명
int MachErrorCodeMACHBASE 에서 제공하는 에러 코드Error code provided by MACHBASE


MachAppendWriter

MachCommand 를 사용하는 별도의 클래스로 APPEND 를 지원한다.
ADO.NET 표준이 아닌, MACHBASE 의 Append Protocol 을 지원하기 위한 클래스이다.

별도의 생성자 없이 MachCommand 의 AppendOpen() 으로 생성된다APPEND is supported as a separate class using MachCommand. 

This is a class to support MACHBASE Append Protocol, not ADO.NET standard.
It is created with MachCommand's AppendOpen () without a separate constructor.


메서드설명
void SetErrorDelegator(ErrorDelegateFuncType aFunc)에러가 발생했을 때 호출할 ErrorDelegateFunc 을 지정한다Specifies the ErrorDelegateFunc to call when an error occurs.


필드설명
SuccessCount입력 성공한 레코드 개수. Number of successful records. Is set after AppendClose() 이후 설정된다.
FailureCount입력 실패한 레코드 개수. The number of records that failed input. Set after AppendClose () 이후 설정된다.
OptionAppendOpenMachAppendOption received input during AppendOpen() 때 입력받은 MachAppendOption


ErrorDelegateFuncType

Code Block
languagecsharp
public delegate void ErrorDelegateFuncType(MachAppendException e);

MachAppendWriter 에서, APPEND 도중 MACHBASE 서버 측에서 발생하는 Error 를 감지하기 위한 함수를 지정할 수 있다.

.NET 에서는 이 함수형을 Delegator Function 으로 지정한다In MachAppendWriter, you can specify a function to detect errors occurring on the MACHBASE server side during APPEND.

In .NET, this function type is specified as a Delegator Function.



MachAppendException : MachException

Same as MachException 과 동일하지만, 다음 점이 다르다.

  • 에러 메시지가 서버 측으로부터 수신된다.
  • 에러가 발생한 데이터 버퍼를 획득할 수 있다. (comma-separated) 이 데이터를 가공해 다시 APPEND 하거나 기록하는 용도로 사용할 수 있다.

해당 예외는 ErrorDelegateFunc 내부에서만 획득이 가능하다, except that:

  • An error message is received from the server side.
  • A data buffer in which an error has occurred can be obtained. (comma-separated) can be used to process and re-append or record data.

The exception is only available within the ErrorDelegateFunc.


메서드설명
GetRowBuffer()에러가 발생한 데이터 버퍼를 획득할 수 있다A data buffer in which an error has occurred can be obtained.


MachTransaction

지원하지 않는다Not supported.

샘플 코드



Sample Code

연결

Connection

MachConnection 을 만들어 You can create a MachConnection and use Open () - Close () 하면 된다.


Code Block
languagecsharp
String sConnString = String.Format("DSN={0};PORT_NO={1};UID=;PWD=MANAGER;", SERVER_HOST, SERVER_PORT);
MachConnection sConn = new MachConnection(sConnString);
sConn.Open();
//... do something
sConn.Close();

using 구문을 사용하면, Connection 종료 작업인 Close() 를 호출하지 않아도 된다If you use the using statement, you do not need to call Close (), which is a connection closing task.

Code Block
languagecsharp
String sConnString = String.Format("DSN={0};PORT_NO={1};UID=;PWD=MANAGER;", SERVER_HOST, SERVER_PORT);
using (MachConnection sConn = new MachConnection(sConnString))
{
    sConn.Open();
    //... do something
} // you don't need to call sConn.Close();
쿼리 수행


Executing Queries

MachCommand 를 만들어 쿼리를 수행하면 된다Create a MachCommand and perform the query.

Code Block
languagecsharp
String sConnString = String.Format("DSN={0};PORT_NO={1};UID=;PWD=MANAGER;", SERVER_HOST, SERVER_PORT);
using (MachConnection sConn = new MachConnection(sConnString))
{
    String sQueryString = "CREATE TABLE tab1 ( col1 INTEGER, col2 VARCHAR(20) )";
    MachCommand sCommand = new MachCommand(sQueryString , sConn)
    try
    {
        sCommand.ExecuteNonQuery();
    }
    catch (MachException me)
    {
        throw me;
    }
}

이 역시 using 구문을 사용하면, MachCommand 해제 작업을 곧바로 진행할 수 있다Again, using the using statement, MachCommand release can be done immediately.

Code Block
languagecsharp
String sConnString = String.Format("DSN={0};PORT_NO={1};UID=;PWD=MANAGER;", SERVER_HOST, SERVER_PORT);
using (MachConnection sConn = new MachConnection(sConnString))
{
    String sQueryString = "CREATE TABLE tab1 ( col1 INTEGER, col2 VARCHAR(20) )";
    using(MachCommand sCommand = new MachCommand(sQueryString , sConn))
    {
        try
        {
            sCommand.ExecuteNonQuery();
        }
        catch (MachException me)
        {
            throw me;
        }
    }
}


Executing SELECT

수행SELECT 쿼리를 가진 MachCommand 를 실행해 MachDataReader 를 얻을 수 있다.
MachDataReader 를 통해 레코드를 하나씩 Fetch 할 수 있다

You can get a MachDataReader by executing a MachCommand with a SELECT query. 

You can fetch the records one by one through the MachDataReader.

Code Block
languagecsharp
String sConnString = String.Format("DSN={0};PORT_NO={1};UID=;PWD=MANAGER;", SERVER_HOST, SERVER_PORT);
using (MachConnection sConn = new MachConnection(sConnString))
{
    String sQueryString = "SELECT * FROM tab1;";
    using(MachCommand sCommand = new MachCommand(sQueryString , sConn))
    {
        try
        {
            MachDataReader sDataReader = sCommand.ExecuteReader();
            while (sDataReader.Read())
            {
                for (int i = 0; i < sDataReader.FieldCount; i++)
                {
                    Console.WriteLine(String.Format("{0} : {1}",
                                                    sDataReader.GetName(i),
                                                    sDataReader.GetValue(i)));
                }
            }
        }
        catch (MachException me)
        {
            throw me;
        }
    }
}

파라메터 바인딩

MachParameterCollection 을 생성한 다음, MachCommand 에 연결해서 수행할 수 있다


Parameter Binding

You can create a MachParameterCollection and then link it to a MachCommand.

Code Block
languagecsharp
String sConnString = String.Format("DSN={0};PORT_NO={1};UID=;PWD=MANAGER;", SERVER_HOST, SERVER_PORT);
using (MachConnection sConn = new MachConnection(sConnString))
{
    string sSelectQuery = @"SELECT *
        FROM tab2
        WHERE CreatedDateTime < @CurrentTime
        AND CreatedDateTime >= @PastTime";

    using (MachCommand sCommand = new MachCommand(sSelectQuery, sConn))
    {
        DateTime sCurrtime = DateTime.Now;
        DateTime sPastTime = sCurrtime.AddMinutes(-1);

        try
        {
            sCommand.ParameterCollection.Add(new MachParameter { ParameterName = "@CurrentTime", Value = sCurrtime });
            sCommand.ParameterCollection.Add(new MachParameter { ParameterName = "@PastTime", Value = sPastTime });

            MachDataReader sDataReader = sCommand.ExecuteReader();

            while (sDataReader.Read())
            {
                for (int i = 0; i < sDataReader.FieldCount; i++)
                {
                    Console.WriteLine(String.Format("{0} : {1}",
                                                    sDataReader.GetName(i),
                                                    sDataReader.GetValue(i)));
                }
            }
        }
        catch (MachException me)
        {
            throw me;
        }
    }
}


APPEND

MachCommand 에서 When you run AppendOpen () 을 수행하면, MachAppendWriter 객체를 얻을 수 있다.이 객체와 MachCommand 를 이용해, 입력 레코드 1건을 리스트로 준비해 AppendData() 를 수행하면 입력이 이뤄진다on a MachCommand, you get a MachAppendWriter object.

Using this object and MachCommand, you can get a list of one input record and perform an AppendData ().
AppendFlush () 를 하면 모든 레코드의 입력이 반영되며, will reflect the input of all records, and AppendClose () 를 통해 Append 전체 과정을 종료할 수 있다will end the entire Append process.


Code Block
languagecsharp
String sConnString = String.Format("DSN={0};PORT_NO={1};UID=;PWD=MANAGER;", SERVER_HOST, SERVER_PORT);
using (MachConnection sConn = new MachConnection(sConnString))
{
    using (MachCommand sAppendCommand = new MachCommand(sConn))
    {
        MachAppendWriter sWriter = sAppendCommand.AppendOpen("tab2");
        sWriter.SetErrorDelegator(AppendErrorDelegator);

        var sList = new List<object>();
        for (int i = 1; i <= 100000; i++)
        {
            sList.Add(i);
            sList.Add(String.Format("NAME_{0}", i % 100));

            sAppendCommand.AppendData(sWriter, sList);

            sList.Clear();

            if (i % 1000 == 0)
            {
                sAppendCommand.AppendFlush();
            }
        }

        sAppendCommand.AppendClose(sWriter);
        Console.WriteLine(String.Format("Success Count : {0}", sWriter.SuccessCount));
        Console.WriteLine(String.Format("Failure Count : {0}", sWriter.FailureCount));
    }
}


Code Block
languagec#
        private static void AppendErrorDelegator(MachAppendException e)
        {
            Console.WriteLine("{0}", e.Message);
            Console.WriteLine("{0}", e.GetRowBuffer());
        }