求助,关于利用bcb 从excel导入sql
excel导入SQL的语句:
Insert into no210.dbo.yous
select *
From OpenDataSource( 'Microsoft.Jet.OLEDB.4.0','Data Source=D:\CPP\no211\yous.xls;User ID=Admin;Password=;Extended properties=Excel 8.0')...sheet1$
在SQLsever 2005中执行成功,并且能够成功的将数据导入,但是在bcb2010中执行不了
语句:
void __fastcall TForm1::Button1Click(TObject *Sender)
{ String mysql;
mysql="Insert into no210.dbo.yous select * From OpenDataSource( 'Microsoft.Jet.OLEDB.4.0','Data Source=D:\CPP\no211\yous.xls;User ID=Admin;Password=;Extended properties=Excel 8.0')...sheet1$"; //可用
this->ADOQuery1->Active=false;
this->ADOQuery1->SQL->Clear();
this->ADOQuery1->SQL->Add(mysql);
this->ADOQuery1->Active=true;
}
执行后提示:链接服务器 "(null)" 的 OLE DB 访问接口 "Microsoft.Jet.OLEDB.4.0" 报错。提供程序未给出有关错误的任何信息。
为什么会这样呢?已经困惑好几天了……
excel
[解决办法]
mysql="Insert?into?no210.dbo.yous?select?*?From?OpenDataSource(?'Microsoft.Jet.OLEDB.4.0','Data?Source=D:\CPP\no211\yous.xls;User?ID=Admin;Password=;Extended?properties=Excel?8.0')...sheet1$";???//可用
改成:
mysql="Insert into no210.dbo.yous select * From OpenDataSource( 'Microsoft.Jet.OLEDB.4.0','Data Source=D:\\CPP\\no211\\yous.xls;User ID=Admin;Password=;Extended properties=Excel 8.0')...sheet1$"; //可用