ADO读取Excel数据
int ADOConn::WriteExcel(int row,int col, int count,int data){
char buffer[4];
printf(buffer,"F%d",col);
_variant_t temp;
_bstr_t bstrSQL="select * from [sheet1$]";
try
{
m_pRecordset.CreateInstance(__uuidof(Recordset));
m_pRecordset->Open(bstrSQL,_variant_t((IDispatch*)m_pConnection,true),adOpenDynamic,adLockOptimistic,adCmdText);
m_pRecordset->MoveFirst();
if (row==1)
{
temp=m_pRecordset->GetCollect(buffer);
m_pRecordset->AddNew();
m_pRecordset->PutCollect("buffer",data);
}
else
{
for (int i=1; i<row; i++)
m_pRecordset->MoveNext();
m_pRecordset->AddNew();
m_pRecordset->PutCollect("buffer",data);
}
m_pRecordset->Update();
}
catch(_com_error &e)
{
printf("%s",e.Description());
}
return 0;
}
void main()
{
ADOConn ado_write;
ado_write.OnInitADOConn_Write(); //到此处无错,这个是链接数据库的函数
ado_write.WriteExcel(1,4,2,1);//输出异常乱码
}
请问错在哪儿了?前面链接数据库是成功了的