SQLConfigDataSource(NULL,ODBC_ADD_DSN,"Microsoft Access Driver (*.mdb)",
"DSN=Personnel\0"
"DBQ=C:\\My Documents\\dq.mdb\0"
"DefaultDir=C:\\My Documents\0"
"Driver={Microsoft Access Driver (*.mdb)}\0"
"DriverId=790\0"
"Deleted=1\0"
"Description=ODBC数据源\0"
"FileType=Access\0"
"JetIniPath=odbcddp.ini\0"
"MaxScanRows=20\0"
"MaxBufferSize=512"
"ImplicitCommitSync=No\0"
"UserCommitSync=No\0"
"Exclusive=1\0"//独占
"ReadOnly=1\0"//只读
"UID=Smith\0"
"SafeTransactions=0\0"
"PWD=Sesame\0"
"DATABASE=dq\0"
"ExtendedAnsiSQL=1\0"
"Statistics=0\0"
"\0")
出错:
InstallDlg.obj : error LNK2001: unresolved external symbol _SQLConfigDataSource@16
Debug/Install.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
怎么回事?
CFile file;
if(file.Open("Finder.exe",CFile::modeRead))
{
::CopyFile("Finder.exe","D:\\1\\Finder.exe",TRUE);
AfxMessageBox("成功安装");
}
else
AfxMessageBox("没有此文件");
虽然“成功安装”,其实并没有成功!为什么?

解决方案 »

  1.   

    在stdafx.h中
    加上
    #include <afxdb.h>
    ::CopyFile("Finder.exe","D:\\1\\Finder.exe",TRUE);
    你并未判断CopyFile 是否成功。
      

  2.   

    首先我不知道你为什么先file.Openq然后CopyFile
    如果你只是想拷贝文件的话,这样就行了
    if(::CopyFile("Finder.exe","D:\\1\\Finder.exe",TRUE))
    {
    AfxMessageBox("成功安装");
    }
    else
    AfxMessageBox("没有此文件");
      

  3.   

    谢谢,我去掉file.open后我成功了,我用File.open是因为我想先判断是否有这个文件,好作出判断,你有好的判断方法吗?我会马上给你分!
      

  4.   

    你的方法是可行的,但要在拷贝以前要使用file.Close();
    CFile file;
    if(file.Open("Finder.exe",CFile::modeRead))
    {
    file.Close();
    ::CopyFile("Finder.exe","D:\\1\\Finder.exe",TRUE);
    AfxMessageBox("成功安装");
    }
    else{
    file.Close()
    AfxMessageBox("没有此文件");
    }
      

  5.   

    use SearchPath() to see if a file exist!
    ---------------
    DWORD SearchPath(
      LPCTSTR lpPath,      // search path
      LPCTSTR lpFileName,  // file name
      LPCTSTR lpExtension, // file extension
      DWORD nBufferLength, // size of buffer
      LPTSTR lpBuffer,     // found file name buffer
      LPTSTR *lpFilePart   // file component
    );
    ------------------------
    char buffer[MAX_PATH];
    char *p;
    if(::SearchPath("D:\\1","Finder.exe",0,MAX_PATH,buffer,&p)>0)
    {
    ::CopyFile("Finder.exe","D:\\1\\Finder.exe",TRUE);
    AfxMessageBox("成功安装");}
      

  6.   

    谢谢,对了,我用SQLConfigDataSource(...)怎么 能够把我的ODBC的数据库Finder.mdb安装到另外一台机子中呢?我写的那种方法好象不行,而且那种方法好象也没有指出数据源。应该怎么写呢?
      

  7.   

    CFileFind finder;
    if (!finder.FindFile ("Finder.exe")){
    AfxMessageBox("没有此文件");
    return;
    }
      

  8.   

    i can give you a full project used sql2000!
    [email protected]
    ----------------------
    http://expert.csdn.net/Expert/topic/1189/1189504.xml?temp=.4786493
    http://expert.csdn.net/Expert/topic/1092/1092602.xml?temp=.8103754