博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

.Net 配置连接语句

Posted on 2007-05-24 10:42  大胸宝腚  阅读(205)  评论(0)    收藏  举报
 

Oracle:

 <appSettings>
   <add key="ConnectionString" value="Data Source=Sysnet;User ID=scott;Password=scott;Integrated Security=False;Persist Security Info=False;Pooling=True" />
  </appSettings>

 

远程IP连接

_ConnectionPtr m_pConn;
CString m_sConn="Provider=MSDAORA.1;Data Source=sode_192.168.3.9"; //使用
ms连接库,sode为SID,192.168.3.9为机器ip
m_pConn.CreateInstance("ADODB.Connection");
try
{
HRESULT hr=m_pConn->Open((_bstr_t)m_sConn,"sodeUser","sodePw",adConnectUnspecified);
if (FAILED(hr))
{
AfxMessageBox("不能连接数据库 source!");
return FALSE;
}
}
catch(_com_error e)
{
AfxMessageBox("不能打开数据库 error!");
return FALSE;
}

 

Sql:

<appSettings>
   <add key="DSN_MSSQLSERVER" value="server=127.0.0.1;database=LEMS;uid=admin;pwd=admin;persist security info=True;packet size=4096" />

</appSettings>