skip to main
|
skip to sidebar
Showing posts with label
ODBC
.
Show all posts
Showing posts with label
ODBC
.
Show all posts
Wednesday, September 30, 2009
Connect Oracle using ODBC
1. Go to control panel and Create a ODBC provider
2. Create a C# console project and insert the code below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Odbc;
namespace testOracle
{
class Program
{
static void Main(string[] args)
{
OdbcConnection myConnection = new OdbcConnection();
myConnection.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=sltest;Uid=scott;Pwd=tiger";
myConnection.Open();
string cmdtxt = null;
OdbcCommand myCommand = new OdbcCommand();
myCommand.Connection = myConnection;
OdbcDataAdapter myAdapter = new OdbcDataAdapter();
cmdtxt = "SELECT * FROM Dept";
Console.WriteLine(cmdtxt);
myCommand.CommandText = cmdtxt;
myAdapter.SelectCommand = myCommand;
OdbcDataReader moddata = default(OdbcDataReader);
moddata = myCommand.ExecuteReader();
while (moddata.Read() == true)
{
try
{
Console.WriteLine(moddata[1]);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
moddata.Close();
myConnection.Close();
}
}
}
Older Posts
Home
Subscribe to:
Posts (Atom)
Code snippets
Blog Archive
▼
2011
(3)
▼
April
(3)
Oracle SQLPlus
css & html tips
How to use SingTel BroadCom
►
2010
(11)
►
October
(1)
►
September
(1)
►
August
(1)
►
June
(1)
►
May
(2)
►
March
(1)
►
February
(1)
►
January
(3)
►
2009
(75)
►
November
(18)
►
October
(36)
►
September
(2)
►
July
(19)