SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Connect to Oracle

rated by 0 users
This post has 3 Replies | 0 Followers

Top 50 Contributor
Posts 65
sukino Posted: 01-15-2008 11:26 AM

Anyone could provide an example to connect to the oracle database? I keep having problem connecting.

Top 25 Contributor
Posts 184
what problems are you encountering? are you using the built-in Oracle data provider that comes with .NET or are you using Oracle's ODP.NET?

http://devpinoy.org/blogs/cruizer

Top 50 Contributor
Posts 65

I am using System.Data.OracleClient.

My current code (just a simple test):

Dim cn As New OracleConnection("Data Source=servicename;User ID=username;Password=pwd;")

Try

Dim da As New OracleDataAdapter("select count(*) from Tablename", cn)

Dim dt As New DataTable

da.Fill(dt)

da.Dispose()

Me.DataGrid1.DataSource = dt

Me.DataGrid1.DataBind()

dt.Dispose()

Catch ex As Exception

Me.Label1.Text = ex.Message

Finally

If cn.State = ConnectionState.Open Then

cn.Close()

End If

End Try

It is returning me : Could not create an environment: OCIEnvCreate returned -1. 

Top 50 Contributor
Posts 65
I changed into OleDb now. Had this Cannot resolve Service Name issue. But resolved it by adding permission for IUSR_computername and IWAM_computername. Finally, I am connecting to oracle.
Page 1 of 1 (4 items) | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems