我想在连接字符串中指定端口和SID。在运行以下代码之后:
public static string ConnectionString
{
get
{
string host = Config.CsHost;
string sid = Config.CsSID;
string port = Config.CsPort;
string user = Config.CsUser;
string pass = Config.CsPassword;
return String.Format(@"Data Source = {0}:{1}\{2}; Persist Security Info = True; User Id = {3}; Password = {4}; Unicode = True", host, port, sid, user, pass);
}
}
...
using (OracleConnection connection = new OracleConnection(ConnectionString))
{
try
{
connection.Open();
Open()方法没有响应……我认为问题出在sid上。可能的问题是什么?
更新: 我应该使用这种连接字符串,但是我无法很好地解释它。
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID))); User Id=myUsername;Password=myPassword;
有人可以帮我解释一下吗?