PDA

Click to See Complete Forum and Search --> : Connection to Oracle in .Net Framework 1.0


Manoj91
Apr 1st, 2006, 09:40 AM
Hi........

I've .Net Framework 1.0 and I want to connect Oracle 8i.

Can I do this in .Net Framework 1.0 ?
( System.Data.Odbc ) namespace does not exist in this version.

plz tell me how can I do it.......it would be more helpful if u post some code here.

Thanks,
Manoj

Manoj91
Apr 1st, 2006, 10:01 AM
huh...

I resolved it and I'm posting my code here for reference.......


//Connection with Oracle.

OleDbConnection Conn = new OleDbConnection() ;
OleDbDataAdapter DA ;
DataTable DT ;

Conn.ConnectionString = @"Provider=MSDAORA.1;Password=tiger;User ID=scott;Data Source=MANOJ" ;
Conn.Open() ;

DA = new OleDbDataAdapter("Select * From Emp", Conn ) ;
DT = new DataTable() ;
DA.Fill(DT) ;
dataGrid1.DataSource = DT ;



//Connection to MS Access.
OleDbConnection Conn ;
OleDbDataAdapter DA ;
DataTable DT ;

Conn = new OleDbConnection() ;
Conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Manoj\MyDatabase.mdb" ;
Conn.Open() ;
DA = new OleDbDataAdapter("Select * From EmpInfo", Conn ) ;

DT = new DataTable() ;
DA.Fill(DT) ;
dataGrid1.DataSource = DT ;



Thanks & Regards
Manoj

GaryMazzone
Apr 1st, 2006, 02:10 PM
Wht connect though ODBC it's more costly then using the direct method.
?

jmcilhinney
Apr 1st, 2006, 05:08 PM
You can download ADO.NET components from Oracle, although it does not mention 8i. I'd download the 9i version and see if that works. The Oracle-specific components will be more efficient and possibly more functional than the more general OleDb.

tablazon
Apr 5th, 2006, 09:48 AM
using System.Data.OracleClient;
(reference:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.OracleClient.dll
from Microsoft site, I believe)

If you don't have the reference, I will be glad to send it.

string Hdrstr = "SERVER=SERVERNAME;UId=MYUSERID;Pwd=thepassword";
OracleConnection HdrConn = new OracleConnection(Hdrstr);
HdrConn.Open();
OracleCommand HdrCmd = HdrConn.CreateCommand();
HdrCmd.CommandText = "SELECT H.RID, H.DATE " +
" FROM JOURNAL_ENTRY H " +
" WHERE H.DATE BETWEEN '" + txtFromDate.Text + "' and '" + txtToDate.Text +
"' ORDER BY H.DATE";
OracleDataReader HdrReader = HdrCmd.ExecuteReader();

The Oracle commands are essentially the same as the OleDb commands.

I am using this on Oracle 8i. It works fairly quickly considering the speed of the machine I'm using.
:duck:

jmcilhinney
Apr 5th, 2006, 04:59 PM
That's not possible in version 1.0 of the Framework tablazon, as the System.Data.OracleClient namespace wasn't added until version 1.1.

tablazon
Apr 6th, 2006, 03:50 PM
Yes, you're right!