请问在BCB中如何将ADO查询出的DBF记录集保存为新的DBF文件

goos9005mlgk 2008-01-19 05:32:43
请问老妖大侠
如何在BCB中如何保存用ADO查询出的记录集保存为新的DBF文件,还有如何将A记录集的记录追加到B记录集中,如记录存在则更新,如不存在则追加,非常急,谢谢大侠了
...全文
195 点赞 收藏 20
写回复
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
liudutian 2012-04-10
Tdbf是控件吗,哪里下,如何用
回复
CACACACACA 2008-04-05
有BatchMove控件, 在BDE页上。
回复
fbmsyu 2008-04-05
我用Tdbf,挺好用的。
回复
goos9005mlgk 2008-01-27
我顶顶,继续求答案
回复
goos9005mlgk 2008-01-26
继续顶
回复
僵哥 2008-01-25
实在不行,估计得更新驱动到VFP8/VFP9
回复
goos9005mlgk 2008-01-25
MyModule->ADOConnection1->Close();
MyModule->ADOConnection1->ConnectionString = "Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=" + DataPath + ";Exclusive=No";
MyModule->ADOConnection1->Open();

MyModule->ADOQuery1->Close();
MyModule->ADOQuery1->Connection = MyModule->ADOConnection1;
MyModule->ADOQuery1->SQL->Clear();
MyModule->ADOQuery1->SQL->Add("select * from mydb.dbf into dbf newdb.dbf")
MyModule->ADOQuery1->ExecSQL();

MyModule->ADOQuery1->Close();
MyModule->ADOConnection1->Close();

不报错,但没任何结果
回复
僵哥 2008-01-25
我已经说过了,首先确定你的驱动对不对。
回复
goos9005mlgk 2008-01-25
回楼上的大侠,用 select * from mydb.dbf into dbf newdb.dbf在BCB里面不报错,但什么也没有做
回复
goos9005mlgk 2008-01-25
谢谢楼上诸位大侠的热心回复,继续顶
回复
Leighf 2008-01-24
一段代码仅供参考:

if (DM->qryLog->RecordCount <= 0)
{
Application->MessageBoxA("表里没有数据!","提示",MB_OK);
return;
}

AnsiString filter = svdlg->Filter,FileDir,filename,tablename;
svdlg->Filter = "DBF 文件(*.Dbf)|*.Dbf";
if(svdlg->Execute() == IDOK)
{
filename = ChangeFileExt(svdlg->FileName,".Dbf");
if (FileExists(filename))
{
if (MessageBox(NULL,"是否覆盖该文件?","消息",MB_YESNO) == IDNO)
return;
else
DeleteFile(filename);
}
filename = ExtractFileName(filename);

AnsiString ffile = ExtractFilePath(Application->ExeName ) + "_Part.dbf";
if (!CopyFile(ffile.c_str(),filename.c_str(),false))
{
Application->MessageBoxA("创建文件失败!","警告",MB_OK);
return;
}
FileDir = ExtractFileDir(svdlg->FileName);
try
{

DM->tblVideo->Close();
DM->tblVideo->DatabaseName = FileDir;
DM->tblVideo->TableName = filename;
DM->tblVideo->Open();

DM->qryLog->First();
for(int i = 0;i < DM->qryLog->RecordCount; i++)
{

DM->tblVideo->Append();
for(int j = 0;j < 12; j++)
//for(int j = 0;j < DM->qryLog->Fields->Count; j++)
{

DM->tblVideo->FieldValues[DM->tblVideo->Fields->Fields[j]->FieldName]
= DM->qryLog->FieldValues[DM->qryLog->Fields->Fields[j]->FieldName];
Application->ProcessMessages();
}
DM->tblVideo->Post();
DM->qryLog->Next();
}
Application->MessageBoxA("导出DBF成功!","提示",MB_OK);
}
catch(...)
{
Application->MessageBoxA("数据库连接错误!", "错误", MB_OK);
}

}
DM->tblVideo->Close();
svdlg->Filter = filter;
回复
Leighf 2008-01-24
可以到这里看看

http://www.ccrun.com/view.asp?id=204
回复
僵哥 2008-01-24
DBF?如果是使用VFP的驱动,可以直接select .... into NewTable.
回复
goos9005mlgk 2008-01-23
有解决过类似问题的大侠没,急啊,分不够可以再加
回复
ydlchina 2008-01-22
顶分
回复
goos9005mlgk 2008-01-22
顶顶
回复
发动态
发帖子
茶馆
创建于2007-08-02

525

社区成员

C++ Builder 茶馆
申请成为版主
社区公告
暂无公告