将ado连接数据库 用adoquery 查询出来的dbgrid数据表,怎样导出成dbf文件呢
各位先谢过了 分不够再加!!
在线等……
各位先谢过了 分不够再加!!
在线等……
解决方案 »
- 改变RichEdit中字体大小
- 我用Canvas画了,然后怎样把画的东西取消????????????
- ShellExecute(0,'print',filename,nil, nil,0);
- 关于网上邻居,急!!!
- 如何获得一个RAR压缩包里的文件数
- 关于Form.SetParent
- COM+问题!如何把要保存的数据记录传递给COM+????请前辈们帮助一下!谢谢
- 急!如何读取word文档中嵌的TextBox构件的内容(使用Delphi6提供的Servers控件)
- 我做的东西怎么打包作成安装程序啊。
- 数组指针!!!!!!
- 有5个表,5个表以字段:ID做关联,请问如何要将5个表中ID值相同的记录以表格形式打印出来
- VCLZip V3.03解压缩问题
procedure TForm1.Button3Click(Sender: TObject);
begin
sSql := 'select * into aaa in ''f:\'' ''dbase 5.0;'' from demo';
with AccessConnection do
begin
Connected := True;
Execute(sSql);
end;
end;
'Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=c:\',
'select * from [aa.DBF]')
select * from 表说明:
SourceDB=c:\ 指定foxpro表所在的文件夹
aa.DBF 指定foxpro表的文件名.
procedure TForm1.Button3Click(Sender: TObject);
begin
sSql := 'SELECT * into table FROM Tab1 IN [ODBC]
[ODBC;Driver=SQL Server;UID=sa;PWD=;Server=127.0.0.1;DataBase=Demo;]';
with AccessConnection do
begin
Connected := True;
Execute(sSql);
end;
end;
----------------------------------------------------------------
花自飘零水自流,一种相思,两处闲愁。
此情无计可消除,才下眉头,又上心头。
----------------------------------------------------------------
想通过adoquery 把查询出来的数据导出到dbf文件中
We can use several providers to open DBF files usind ADODB. Basic way is to use ODBC data source (DSN or DSNless), there is several samples published on web. But how to open DBF files without ODBC? There are two other OLEDB providers, using which you can work with DBF files. One of them is Microsoft.Jet.OLEDB.
Key property to work with DBF files is "Extended Properties" - there is no much info about this parameter in documentation. This parameter has similar meaning as connect parameter in DAO OpenDatabase method. First work is to open connection to DBASE IV files:
Function OpenDBFConn(Path)
Dim Conn: Set Conn = CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Path & ";" & _
"Extended Properties=""DBASE IV;"";"
Set OpenDBFConn = Conn
End Function2. Other ISAM formats, FoxPro
"DBASE IV" is one of ISAM format. You can find installed ISAM formats in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\ISAM Formats\
registry key. You can use other formats - "dBase 5.0", "Paradox 3.X", "Outlook 9.0" etc.
But what about FoxPro files? Microsoft.Jet.OLEDB.4.0 does not support FoxPro 2.0 - 3.0 as ISAM parameter - you cannot see this ISAM engine in Jet\4.0\ISAM Formats lists. You can do some small work around of this feature - import FoxPro ISAM from Jet\3.5 key. Create small .reg file with the next information:REGEDIT4[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\ISAM Formats\FoxPro 3.0]
"Engine"="Xbase"
"ExportFilter"="Microsoft FoxPro 3.0 (*.dbf)"
"CanLink"=hex:00
"OneTablePerFile"=hex:01
"IsamType"=dword:00000000
"IndexDialog"=hex:00
"CreateDBOnExport"=hex:00
"ResultTextExport"="Export data into a Microsoft FoxPro 3.0 file."
"SupportsLongNames"=hex:00
Then you can use
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Path & ";" & _
"Extended Properties=""FoxPro 3.0;"";" 3. Work with DBF connection
So, what we can do with the connection? You can use any ODBC statement (Create table, Insert Into, Delete, Select ...). You can address the table using several ways:Select * from Persons
Select * from Persons.DBF
Insert Into Persons#DBF Values (...)
Delete * from [Persons.DBF] Where ...Create Table [Any Long File Name You Want] As ...
4. Real VBS samples
Open DBF connection, create table, insert records, get recordset.
'Open connection For DBF files In F:\ folder
Dim DBConn
Set DBConn = OpenDBFConn("f:\")'Create a new DBF file named Persons.DBF
DBConn.Execute "Create Table Persons (Name char(50), City char(50), Phone char(20), Zip decimal(5))"'Insert some row To the table
DBConn.Execute "Insert into Persons Values('Alex P. Nor', 'Mexico','458962146','14589')"'Open recordset from Persons table
Dim Persons
Set Persons = DBConn.Execute("Select * from [Persons#DBF]")'Output the recordset In csv format
Wscript.Echo Persons.GetString(,-1, ", ", vbCrLf)