Tuesday, June 21, 2011

connectivity of oracle and c#


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Data.Odbc;
namespace WindowsApplication12
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           OdbcConnection con=new OdbcConnection ("driver={microsoft odbc for oracle};uid=scott;pwd=tiger;");
            OdbcCommand cmd=new OdbcCommand ("select * from emp",con );
            OdbcDataAdapter da=new OdbcDataAdapter (cmd);
            DataSet ds=new DataSet();
            da.Fill(ds);
            dataGridView1.DataSource  = ds.Tables[0];
   


        }
    }
}

1 comment: