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