Saturday, June 25, 2011

Connect Oracle10g Database with DotNet Framework using C#


Namespaces


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

Button Click Event to Display Data on DataGridView


private void button1_Click(object sender, EventArgs e)
{
string connectionString = "provider=MSDAORA;data source=ORCL;user id=SCOTT;password=TIGER";
OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
OleDbDataAdapter da = new OleDbDataAdapter("select * from emp",myOleDbConnection );
DataSet ds = new DataSet();
da.Fill(ds, "emp");
dataGridView1.DataSource = ds.Tables["EMP"].DefaultView;
}


1 comment:

  1. still Required hard coded connection string ha ha ha ha

    ReplyDelete