急!急!急!如何在vc中打开数据库后用嵌入式的sql查询 打开.dbf后,怎么实现表的spl查询,选择等 或者能不能打开整个数据库,用嵌入式的spl查询 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用的是vfp的数据库!CString strCommand; strCommand = "SELECT * FROM pt WHERE pno="+ strItem; m_pCommand.CreateInstance("ADODB.Command"); m_pCommand->ActiveConnection = theApp.m_pConnection; // 将库连接赋于它 m_pCommand->CommandText = _bstr_t(strCommand); m_pPtRecord = m_pCommand->Execute(NULL, NULL,adCmdText);//在这里出错! file->new win32 console project.empty project.add vfp.cpp#include <windows.h>#include <stdio.h>#import "c:\Program Files\Common Files\System\ADO\msado20.tlb" \ no_namespace rename("EOF", "EndOfFile")void PrintProviderError(_ConnectionPtr pConnection){ ErrorPtr pErr = NULL; if( (pConnection->Errors->Count) > 0) { long nCount = pConnection->Errors->Count; for(long i = 0;i < nCount;i++) { pErr = pConnection->Errors->GetItem(i); printf("\t Error number: %x\t%s", pErr->Number,pErr->Description); } }}void main(){ if(FAILED(::CoInitialize(NULL))) return ; _ConnectionPtr pConnection = NULL; _bstr_t strConnection = TEXT("Driver={Microsoft dBASE Driver (*.dbf)};DBQ=C:\\; DriverID=533;"); try { _RecordsetPtr pRstSchema = NULL; _CommandPtr pCommand=NULL; pConnection.CreateInstance(__uuidof(Connection)); pConnection->Open (strConnection, "", "", -1); pCommand.CreateInstance (__uuidof(Command)); pRstSchema.CreateInstance (__uuidof(Recordset)); _bstr_t sqltext="select * from jck98 "; pCommand->ActiveConnection =pConnection; pCommand->CommandText =sqltext; pCommand->CommandType=adCmdText; pRstSchema = pCommand->Execute (NULL,NULL,adCmdText); _variant_t filed[17]; _bstr_t filedname[17]; while (!pRstSchema->EndOfFile ) { long kk=pRstSchema->GetFields ()->GetCount (); for (long uu=0;uu<kk;uu++) { filedname[uu]=pRstSchema->GetFields ()->GetItem ((_variant_t)uu)->GetName (); filed[uu]=pRstSchema->GetCollect (filedname[uu]); } pRstSchema->MoveNext (); } pRstSchema->Close(); pConnection->Close(); } catch(...) { PrintProviderError(pConnection); } ::CoUninitialize(); } my dbf name is c:\jck98.dbf 下面图中x+1、y+1//是什么意思? 【求助】在线等,请各种牛人们帮忙看下…… 如何应用FFT变换后的数据绘制频谱图 江湖救急!!在线等!马上给分! 请问谁有电压表的样例,用mscomm控件的那种,急! 我的猴年第一问:如何用程序实现自动执行点击右键出现的菜单命令? 如何有一个资源的句柄得到该资源的ID号? 请教高手:用vc调用matlab的问题,有如下代码 困惑?困惑?困惑?困惑? 如何在基于CFOrmView的SDI文档中内嵌属性表?在线等待! 有关编辑框中汉字显示的问题? what are smart pointer and dumb pointer?
CString strCommand;
strCommand = "SELECT * FROM pt WHERE pno="+ strItem;
m_pCommand.CreateInstance("ADODB.Command");
m_pCommand->ActiveConnection = theApp.m_pConnection; // 将库连接赋于它
m_pCommand->CommandText = _bstr_t(strCommand);
m_pPtRecord = m_pCommand->Execute(NULL, NULL,adCmdText);//在这里出错!
#include <windows.h>
#include <stdio.h>
#import "c:\Program Files\Common Files\System\ADO\msado20.tlb" \
no_namespace rename("EOF", "EndOfFile")
void PrintProviderError(_ConnectionPtr pConnection)
{
ErrorPtr pErr = NULL;
if( (pConnection->Errors->Count) > 0)
{
long nCount = pConnection->Errors->Count;
for(long i = 0;i < nCount;i++)
{
pErr = pConnection->Errors->GetItem(i);
printf("\t Error number: %x\t%s", pErr->Number,pErr->Description);
}
}
}
void main()
{
if(FAILED(::CoInitialize(NULL)))
return ;
_ConnectionPtr pConnection = NULL;
_bstr_t strConnection = TEXT("Driver={Microsoft dBASE Driver (*.dbf)};DBQ=C:\\; DriverID=533;");
try
{
_RecordsetPtr pRstSchema = NULL;
_CommandPtr pCommand=NULL;
pConnection.CreateInstance(__uuidof(Connection));
pConnection->Open (strConnection, "", "", -1);
pCommand.CreateInstance (__uuidof(Command));
pRstSchema.CreateInstance (__uuidof(Recordset));
_bstr_t sqltext="select * from jck98 ";
pCommand->ActiveConnection =pConnection;
pCommand->CommandText =sqltext;
pCommand->CommandType=adCmdText; pRstSchema = pCommand->Execute (NULL,NULL,adCmdText);
_variant_t filed[17];
_bstr_t filedname[17];
while (!pRstSchema->EndOfFile )
{
long kk=pRstSchema->GetFields ()->GetCount ();
for (long uu=0;uu<kk;uu++)
{
filedname[uu]=pRstSchema->GetFields ()->GetItem ((_variant_t)uu)->GetName ();
filed[uu]=pRstSchema->GetCollect (filedname[uu]);
}
pRstSchema->MoveNext ();
}
pRstSchema->Close();
pConnection->Close();
}
catch(...)
{
PrintProviderError(pConnection);
}
::CoUninitialize();
}