ASP. NET connects Oracle database via ODBC

Source: Internet
Author: User
Tags dsn

There was a project to install Oracle The client then lets ASP. System.Data.OracleClient to access the Oracle database, but does not know why it is always reported: ORA-12170: The connection timed out error (the client's server configuration is: Windows server R2 64bit The Oracle client I just started was 32bit, and the last thing to report: Require Oracle version 8.1 or later what ... No way I had to uninstall this version, and then downloaded an Oracle Client 64bit to install on the Oracle official website, the installation will not have this problem, tnsping,ping,telnet Ip 1521 is a pass, but is not connected, But others can connect, but I do not, in the online search a lot of posts, the article can not solve the problem, in the customer's time, the customer network group personnel said: The network is through, this is not the network reason! The staff of the customer's database group said: The database installation is right, this is not the reason for the database! You are a damn this is kidding, I am also drunk, in the group asked them to help me solve this problem, all say is TNS problem, but TNS are configured through the net manager, what the space does not exist things, so it is not the issue of TNS, Then a group of friends jokingly said to me: Congratulations, you ghost! Finally there is a big God in the group, he gave me a dbvis_windows_8_0_10 software, seemingly through Java to connect the database, and then quote: Ojdbc6.jar can access!!! That's why, I'm not sure, but my project is ASP. So even if it's connected, it's no use to me, so I have to think of other ways to connect to Oracle, and then search the Internet for articles on the web, and see what you can do without installing Oracle Client to access oracle!!!

Finally I found, can be connected through ODBC to access Oracle, and then refer to a few online articles to do the configuration, run, it is true, but in this process also took a lot of detours: the following

1, do not need to be on-premises, or the server on the device ODBC data source, but you very much through the local settings, then your Web. config under the connection string can be written like this:

<key= "Oracle"  value= "dsn=155oracle; Uid=zhangwei; Pwd=zhangwei "/>

So you can access the database, but, I say, but why do I not set up the data source it! You want to ah, the user to access your database to set up a local ODBC data source, obviously this is not the right way, of course, this is also good, can be used as testing, but not for production purposes. So how do we write the connection string in the production environment, as follows:

<key= "Oracle"  value= "Driver={microsoft ODBC for Oracle}; server=192.168.1.155/znxj; Uid=zhangwei; Pwd=zhangwei "/>

Note: In the italic section above, if you deploy on the server this IP is not required.

Summarize:

1, in the configuration of the ODBC data source is not the user name is wrong, the server is wrong, anyway, I did not know which is right, and finally can be successful also rely on my own experience slowly change the right, some articles on the Internet are not all right, this hope that we have reservations.

Reference article:

ODBC dsn-less

c#/. NET connection string collation for various mainstream databases (SQL Server,mysql,microsoft access,db2,oracle)

ODBC Data source Connection Oracle Database sample

Connect to Oracle database via ODBC

Four ways to connect to Oracle database in C #

ASP. NET connects Oracle database via ODBC

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.