请问,如何用SQLConfigDataSource为oracle动态配置数据源??

fleg 2005-09-20 01:28:50
请问,如何用SQLConfigDataSource为oracle动态配置数据源,

主要是需要那些属性,如DSN,server等,急,谢谢。
...全文
141 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kudeet 2005-09-20
  • 打赏
  • 举报
回复
CString sPath;
GetModuleFileName(NULL,sPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH);
sPath.ReleaseBuffer ();
int nPos;
nPos=sPath.ReverseFind ('\\');
sPath=sPath.Left (nPos);
nPos=sPath.ReverseFind('\\');
sPath=sPath.Left (nPos);
CString lpszFile = sPath + "\\lhwy.mdb";


char* szDesc;
int mlen;
szDesc=new char[256];
sprintf(szDesc,"DSN=%s? DESCRIPTION=TOC support source? DBQ=%s? FIL=MicrosoftAccess? DEFAULTDIR=%s?? ","lhwy",lpszFile,sPath);



mlen = strlen(szDesc);
for (int i=0; i<mlen; i++)
{
if (szDesc[i] == '?')
szDesc[i] = '\0';
}

if (FALSE == SQLConfigDataSource(NULL,ODBC_ADD_DSN,"Microsoft Access Driver (*.mdb)\0",(LPCSTR)szDesc))
AfxMessageBox("SQLConfigDataSource Failed");


try
{
CString strConnect;
strConnect.Format("DSN=lhwy;");
if(!m_DB.OpenEx(strConnect,CDatabase::useCursorLib))
{
AfxMessageBox("Unable to Connect to the Specified Data Source");
return FALSE ;
}
}
catch(CDBException *pE)
{
pE->ReportError();
pE->Delete();
return FALSE;
}

4,018

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧