윈도우에서 폼 하나 적당히 만드시고 DataGridView추가 후 아래 소스 참조해서 코딩 하세요...
오라클 접속 정보는 적당히 수정(Data Source는 tnsnames.ora 파일에 저장된 alias 이름입니다)
using System.Data.OleDb; //for OleDbConnection, OleDbCommand , etc
using System.Data; //for DataSet
using System.Windows.Forms; //DataGrid, Form
using System; //for String
using System.Data; //for DataSet
using System.Windows.Forms; //DataGrid, Form
using System; //for String
class GridForm : Form
{
private DataGrid dataGrid1 ;
{
private DataGrid dataGrid1 ;
public GridForm()
{
AutoScaleBaseSize = new System.Drawing.Size(6, 14);
ClientSize = new System.Drawing.Size(544, 342);
Load += new System.EventHandler(this.Form1_Load);
{
AutoScaleBaseSize = new System.Drawing.Size(6, 14);
ClientSize = new System.Drawing.Size(544, 342);
Load += new System.EventHandler(this.Form1_Load);
dataGrid1 = new DataGrid();
dataGrid1.Name = "dataGrid1";
dataGrid1.Size = new System.Drawing.Size(520, 312);
Controls.Add(this.dataGrid1);
}
dataGrid1.Name = "dataGrid1";
dataGrid1.Size = new System.Drawing.Size(520, 312);
Controls.Add(this.dataGrid1);
}
OleDbConnection Conn;
OleDbCommand myCommand;
DataSet myDataSet;
OleDbDataAdapter myAdapter;
OleDbCommand myCommand;
DataSet myDataSet;
OleDbDataAdapter myAdapter;
private void Form1_Load(object sender, System.EventArgs e)
{
try
{
//-------------------------------------------------------------------------------
//아래는 오라클용 접속 문자열, wink는 net service 이름
//-------------------------------------------------------------------------------
string ConStr = ("Provider=MSDAORA;data source=WINK;User ID=scott;Password=tiger");
Conn = new OleDbConnection(ConStr);
Conn.Open();
String sql = "select * from emp ";
myCommand = new OleDbCommand(sql, Conn);
myAdapter = new OleDbDataAdapter();
myCommand.CommandType = CommandType.Text ;
myAdapter.SelectCommand = myCommand;
{
try
{
//-------------------------------------------------------------------------------
//아래는 오라클용 접속 문자열, wink는 net service 이름
//-------------------------------------------------------------------------------
string ConStr = ("Provider=MSDAORA;data source=WINK;User ID=scott;Password=tiger");
Conn = new OleDbConnection(ConStr);
Conn.Open();
String sql = "select * from emp ";
myCommand = new OleDbCommand(sql, Conn);
myAdapter = new OleDbDataAdapter();
myCommand.CommandType = CommandType.Text ;
myAdapter.SelectCommand = myCommand;
myDataSet = new DataSet();
myAdapter.Fill(myDataSet, "emp");
myAdapter.Fill(myDataSet, "emp");
dataGrid1.DataSource = myDataSet;
dataGrid1.DataMember = "emp";
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "emp Table Loading");
}
finally
{
Conn.Close();
}
}
}
dataGrid1.DataMember = "emp";
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "emp Table Loading");
}
finally
{
Conn.Close();
}
}
}
class Displayform
{
static void Main()
{
System.Windows.Forms.Application.Run(new GridForm());
}
}
{
static void Main()
{
System.Windows.Forms.Application.Run(new GridForm());
}
}
![]() | ![]() ![]() | 12-27 | 2614 | |
![]() | ![]() ![]() | 12-11 | 1890 | |
53 | ![]() ![]() | 03-15 | 1706 | |
52 | ![]() ![]() | 01-31 | 1813 | |
51 | ![]() ![]() | 01-31 | 2660 | |
50 | ![]() ![]() | 01-31 | 1422 | |
49 | ![]() ![]() | 01-19 | 1741 | |
48 | ![]() ![]() | 01-11 | 1631 | |
47 | ![]() ![]() | 01-03 | 2150 | |
46 | ![]() ![]() | 12-27 | 2614 | |
45 | ![]() ![]() | 12-19 | 1856 | |
44 | ![]() ![]() | 12-14 | 1826 | |
43 | ![]() ![]() | 12-11 | 1890 | |
42 | ![]() ![]() | 12-09 | 1483 | |
41 | ![]() ![]() | 12-01 | 1715 | |
40 | ![]() ![]() | 12-01 | 1887 | |
39 | ![]() ![]() | 12-01 | 1359 |
댓글 없음:
댓글 쓰기