첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ DataTable 클래스의 ImportRow 메소드를 사용해 다른 데이터 테이블의 DataRow 객체를 가져오는 방법을 보여준다.

TestProject.zip
0.00MB

▶ Program.cs

using System.Data;

namespace TestProject;

/// <summary>
/// 프로그램
/// </summary>
class Program
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Method
    ////////////////////////////////////////////////////////////////////////////////////////// Static
    //////////////////////////////////////////////////////////////////////////////// Private

    #region 프로그램 시작하기 - Main()

    /// <summary>
    /// 프로그램 시작하기
    /// </summary>
    private static void Main()
    {
        DataTable sourceTable = new DataTable();

        sourceTable.Columns.Add("ID"  , typeof(int   ));
        sourceTable.Columns.Add("NAME", typeof(string));

        sourceTable.Rows.Add(1, "홍길동");

        DataTable targetTable = new DataTable();

        targetTable.Columns.Add("ID"  , typeof(int   ));
        targetTable.Columns.Add("NAME", typeof(string));

        targetTable.ImportRow(sourceTable.Rows[0]);

        Console.WriteLine(targetTable.Rows[0]["ID"  ]);
        Console.WriteLine(targetTable.Rows[0]["NAME"]);
    }

    #endregion
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요