윈도우에서 폼 하나 적당히 만드시고 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());
}
}
[100%환급외,실무전문]빅데이터/SQL/자바/스프링/안드로이드/닷… | 12-27 | 2708 | ||
[채용확정무료교육]오라클자바개발잘하는신입뽑기2개월과정,교육… | 12-11 | 1956 | ||
53 | [평일100%환급7건]Spring,자바&JSP,안드로이드,웹퍼블리싱,C#닷… | 03-15 | 1781 | |
52 | [주말]C#,ASP.NET마스터 | 01-31 | 1936 | |
51 | [기업100%환급,평일주간]SQL기초에서스키마오브젝트,PLSQL,힌트… | 01-31 | 2831 | |
50 | [주말주간]자바&웹,jQUERY,스프링프레임워크,마이바티스 | 01-31 | 1487 | |
49 | [평일주간,평일야간,주말]Spring,MyBatis,Hibernate개발자과정-… | 01-19 | 1819 | |
48 | [평일야간,주말]안드로이드개발자과정(Android기초실무) | 01-11 | 1694 | |
47 | [평일야간,주말주간야간]JAVA,Network&JSP&Spring,MyBatis,Hiber… | 01-03 | 2237 | |
46 | [100%환급외,실무전문]빅데이터/SQL/자바/스프링/안드로이드/닷… | 12-27 | 2708 | |
45 | [평일주간]NoSQL,MongoDB,빅데이터기초과정 | 12-19 | 1916 | |
44 | [평일주간야간, 주말]웹퍼블리싱 마스터(HTML5,CSS3,jQUERY,AJAX… | 12-14 | 1894 | |
43 | [채용확정무료교육]오라클자바개발잘하는신입뽑기2개월과정,교육… | 12-11 | 1956 | |
42 | [평일주간]빅데이터하둡기초과정(BigData Hadoop) | 12-09 | 1541 | |
41 | [평일야간]닷넷(C#,Network,ADO.NET,ASP.NET)마스터 | 12-01 | 1767 | |
40 | [기업100%환급]오라클&자바웹스프링신입과정3주(SQL,JAVA,JSP,Se… | 12-01 | 1973 | |
39 | [평일야간,주말]SQL기초에서실무까지(SQL기초,PLSQL,힌트,튜닝) | 12-01 | 1410 |
댓글 없음:
댓글 쓰기