Gert .Net
[GertDotNet]
20041206
The connection string to Oracle
Parts that make up the connection string:
- User ID: Very obvious
- Password: Also obvious
- Data Source: MSDN says Server name
This makes a connection string like this:
User ID=MyName;Password=Asecret007;Data Source=server_database
But actually this is the name in the TNSNames.Ora file that maps to a full blown connection string.
The TNSNames.Ora can be found (on my system):
C:\oraNT\NETWORK\ADMIN\Tnsnames.ora.
You can built it using the Oracle Net Configuration Assistant. Choose "Local Net Service Name configuration" to Add, modify or delete.
I noticed that the OracleConnection fails when the Data Source is longer as 16 characters.
Example:
try {
using (OracleConnection con = new OracleConnection(
"User ID=MyName;Password=Asecret007;Data Source=server_database")) {
con.Open();
}
MessageBox.Show(this, "Connection successfull", "Success");
} catch (Exception ex) {
MessageBox.Show(this, "Connection failed\n" + ex.Message, "Connection failed");
}
Comments:
Een reactie plaatsen
Links to this post:
