C # Remote connection to Oracle database

Source: Internet
Author: User
Tags oracleconnection

With this method, only a few necessary parameters can be passed to test the remote connection of the database, and the connection returns true successfully, and the failure returns false. Description: The first parameter indicates that you are a user in the database, the second parameter that has the ability to log on indicates the user's password, no encryption The third parameter indicates the address of the logged on server The fourth parameter indicates the port number of the logged on server The fifth parameter indicates the name of the login database must remember the necessary references// <summary>
Test Database Connectivity
</summary>
public static bool Db_connection_test (string str_uid, String str_pwd, String str_serveraddr, String str_port,string str_d Bname, ref string strerr)
{
String str_conn = String. Format ("User id={0};p assword={1};d ata source= (description= (address=) (Protocol=tcp}) (Host={2}) (port={3 Data= (Service_name={4})) ", Str_uid, Str_pwd, Str_serveraddr, Str_port, str_dbname);Connection string Formatting         OracleConnection Conn = new OracleConnection (str_conn); Defining a Connection instance
Try
{
Conn.Open (); Test the connection instance by opening the connection in its own way
Conn.close ();
return true;
}
catch (Exception ex)
{
Strerr = ex. Message;
return false;
}
}

C # Remote connection to Oracle database

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.