2012. 1. 8. 01:36
급하게 테스트시 dataset 을 만들기 위해 xml 이나 db 로딩 말고 수동으로 만들때가 있다..
private DataTable GetDT()
{
DataTable dtdataTable = new DataTable();
DataColumn col = new DataColumn("SEQ", typeof(Int32));
col.AutoIncrementSeed = 1;
col.AutoIncrement = true;
col.AutoIncrementStep = 1;
col.Caption = "Value ID";
dtdataTable.Columns.Add(col);
DataColumn[] Keys = new DataColumn[2];
Keys[0] = col;
dtdataTable.PrimaryKey = Keys;
col = new DataColumn("TITLE", typeof(string));
dtdataTable.Columns.Add(col);
col = new DataColumn("CONTENTS", typeof(string));
dtdataTable.Columns.Add(col);
//col = new DataColumn("Value", typeof(string));
//col.MaxLength = 50;
//dtdataTable.Columns.Add(col);
//col = new DataColumn("DateTime", typeof(Int32));
//dtdataTable.Columns.Add(col);
ArrayList ar = new ArrayList();
ar.Add(1);
ar.Add("a");
ar.Add("b");
dtdataTable.LoadDataRow(ar.ToArray(), true);
ar.Clear();
ar.Add(2);
ar.Add("c");
ar.Add("d");
dtdataTable.LoadDataRow(ar.ToArray(), true);
return dtdataTable;
'PP > TIP' 카테고리의 다른 글
ASP.NET에서 오류 보고 페이지를 만드는 방법 (0) | 2012.01.08 |
---|---|
제네릭 처리기를 이용하여 자동가입방지 폼 구현 (0) | 2012.01.07 |
C# 인터넷 연결 체크하기 (0) | 2012.01.07 |
자동 업데이트 (0) | 2012.01.07 |
HttpContext, HttpWebRequest, HttpWebResponse, Application 등의 경로 (0) | 2012.01.07 |