odbc数据源加载的问题
自己写的一段程序,在调用SQLConfigDataSource的时候,属性用字符串就不行,可是把路径直接写进去就不行,不知道为什么,明明字符串里的和直接写的路径是一样的阿
char path[255];
GetCurrentDirectory(255,path);
strcat(path,"\\db1.mdb\0");
char des[255];
strcpy(des,"DSN=login\\0DBQ=");
// TRACE(des);
char attribute[255];
int i=0,j=0;
while(path[i]!='\0')
{
if (path[i]!='\\')
{
attribute[j]=path[i];
}
else
{
attribute[j++]='\\';
attribute[j]=path[i];
}
i++;
j++;
}
attribute[j++]='\\';
attribute[j++]='0';
attribute[j++]='\\';
attribute[j++]='0';
attribute[j++]='\0';
strcat(des,attribute);
TRACE(des);
SQLConfigDataSource(NULL,
ODBC_ADD_SYS_DSN,
"Microsoft Access Driver (*.mdb)\0",
des);
如果des换成"DSN=login\0DBQ=C:\\Documents and Settings\\wonder\\桌面\\复件record\\ChatServer\\db1.mdb\0\0"); 就没有问题了,不知道是哪里出错了