关于动态连接excel表的问题
如题,想要通过设置ConnectionString属性动态连接excel表,代码如下:
ADOConnection1->Connected = false;
ADOConnection1->ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Documents and Settings\Administrator\桌面\Colleages.xls;Extended Properties=Excel 8.0;Persist Security Info=False";
ADOConnection1->Connected = true;
ADOQuery1->Active=false;
ADOQuery1->SQL->Add("Select * from [sheet1$]");
ADOQuery1->Open();
ADOQuery1->Active=true;
运行后先弹出DataBase Login对话框,填写用户名Admin,密码为空后提示:创建文件失败。这是为什么?怎么改???
另外,不用ADOConnection直接用ADOQuery连接,代码如下:
ADOQuery1->Active=false;
ADOQuery1->ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Documents and Settings\Administrator\桌面\Colleages.xls;Extended Properties=Excel 8.0;Persist Security Info=False";
ADOQuery1->SQL->Add("Select * from [sheet1$]");
ADOQuery1->Open();
ADOQuery1->Active=true;
运行后也提示:创建文件失败。咋改啊???
[解决办法]
把路径中的\换成\\