Rajar Ahmed
asked on
Connect oracle database in asp.net
Trying to import oracle objects and make some crud operation to work in asp.net application as we do it in sql database using system.data.sqlclient . But i get these errors which i attached on the image.
I installed the ODAC112030_x64.zip version on my pc ,
http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html
Using oracle 11g,sql oracle developer
oracleErrorWhileInvokingAsp.net.png
Imports Oracle.DataAccess
Partial Class firstOracle
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As New OracleConnection
End Sub
End Class
I installed the ODAC112030_x64.zip version on my pc ,
http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html
Using oracle 11g,sql oracle developer
oracleErrorWhileInvokingAsp.net.png
ASKER
i get these warnings still
I use both express edition of vs2010,vs2012 frequently . now this error on vs2010 .
Warning 4 Namespace or type specified in the Imports 'Oracle.DataAccess.Types' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
Warning 4 Namespace or type specified in the Imports 'Oracle.DataAccess.client' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
Also make sure your VS project is set up to be 64bit since you installed the 64bit ODAC?How to check this ?
I use both express edition of vs2010,vs2012 frequently . now this error on vs2010 .
>>i get these warnings still
Did you add a reference in the project to Oracle.DataAccess.dll?
>>How to check this ?
Check this out:
http://www.brianpeek.com/post/2007/11/13/x64-development-with-net.aspx
Did you add a reference in the project to Oracle.DataAccess.dll?
>>How to check this ?
Check this out:
http://www.brianpeek.com/post/2007/11/13/x64-development-with-net.aspx
ASKER
still error after adding reference, i dint find any selection of processor on configurationmanager.
stillErrorAfterAddingReference.png
ijustfindthisnox86x64.png
stillErrorAfterAddingReference.png
ijustfindthisnox86x64.png
From your previous question: Do you still have a reference in the web.config and did you manually add it?
ASKER
hi slightwv,
yes , now am getting object from orace.dataaccess.client.
but am getting this error,
What am i missing ?
Meeran03
yes , now am getting object from orace.dataaccess.client.
but am getting this error,
Connection string is not well-formed ,
myfirstuser is the database which we created freshly on last post Imports Oracle.DataAccess.Client
Imports System.Data
Partial Class firstOracle
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim oradb As String = "User Id=myfirstuser;Password=myPassword;Data Source=localhost" 'Trying to connect using this oracle connection
Dim sql As String = "select sysdate from dual;"
Dim adapter As New OracleDataAdapter(oradb, sql)
Dim builder As New OracleCommandBuilder(adapter)
Dim dataset As New DataSet()
adapter.Fill(dataset, "t_mobile")
Dim mytable As DataTable = dataset.Tables("t_mobile")
End Sub
End Class
What am i missing ?
Meeran03
>>Data Source=localhost
Data Source in ODP.Net is the entry in the tnsnames.ora file.
try this:
Dim oradb As String = "User Id=myfirstuser;Password=my Password;D ata Source=XE" 'Trying to connect using this oracle connection
Data Source in ODP.Net is the entry in the tnsnames.ora file.
try this:
Dim oradb As String = "User Id=myfirstuser;Password=my
ASKER
Am still getting the same error , while trying with your connection string also.
This is my ora file .
This is my ora file .
<data source alias> =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <hostname or IP>)(PORT = <port>))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = <database service name>)
)
)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is where it located .
C:\oraclexe\app\oracle\pro duct\11.2. 0\server\n etwork\ADM IN\
And the file content is below.
Am getting this , after interchanging to sql,oradb
ORA-12154: TNS:could not resolve the connect identifier specified
C:\oraclexe\app\oracle\pro
And the file content is below.
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname-pc)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
);
EXTPROC_CONNECTION_DATA =
.................
ORACLR_CONNECTION_DATA =
----------
Am getting this , after interchanging to sql,oradb
ORA-12154: TNS:could not resolve the connect identifier specified
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yaaaa got it.....This connection works.
Thank you for the support.
Meeran03
Dim oradb As String = "User Id=myfirstuser;Password=myPassword;Data Source=localhost;"
Thank you for the support.
Meeran03
I'm not sure why just "localhost" works. I've never seen a connection string for .Net work this way.
It may not work for you moving forward.
It may not work for you moving forward.
ASKER
hi slightwv,
What i thought initially?
To connect oracle from .net we just need a oracle database and oracle.dataaccess.dll but i was totally wrong its odac was doing the underground work.I hope am right on this:).
Thanks&Regards
Meeran03
I've never seen a connection string for .Netwhile using sql server we used to connect such a way only in local source , i tried the same for oracle . luckily it was working .
It may not work for you moving forwardWell, yes , thats a valid point . I may ask a seperate thread if am stuck .
What i thought initially?
To connect oracle from .net we just need a oracle database and oracle.dataaccess.dll but i was totally wrong its odac was doing the underground work.I hope am right on this:).
Thanks&Regards
Meeran03
>>while using sql server we used to connect such a way only in local source , i tried the same for oracle .
You really can't compare SQL Server to Orcle this way. If you were to create a new database intance, it is stand alone. It doesn't run in a Server like SQL Server. Using localhost will likely get confused.
Oracle mainly either uses EZConnect or references the tnenames,ora file.
using localhost the way you did is likely thinking EZCONNECT and can find the XE instance.
>>but i was totally wrong its odac was doing the underground work.I hope am right on this:).
You need a properly configured Oracle Client. Some use a third party like DotNetConnect which doesn't require an Oracle client. Most use an Oracle client.
You really can't compare SQL Server to Orcle this way. If you were to create a new database intance, it is stand alone. It doesn't run in a Server like SQL Server. Using localhost will likely get confused.
Oracle mainly either uses EZConnect or references the tnenames,ora file.
using localhost the way you did is likely thinking EZCONNECT and can find the XE instance.
>>but i was totally wrong its odac was doing the underground work.I hope am right on this:).
You need a properly configured Oracle Client. Some use a third party like DotNetConnect which doesn't require an Oracle client. Most use an Oracle client.
Imports Oracle.DataAccess
Add:
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Also make sure your VS project is set up to be 64bit since you installed the 64bit ODAC.