Generally, the record set is searched or summarized in access or SQLSERVER, and then a 'record set' is generated, which can be displayed in the GRID or exported to the disk. Below we can export Xls, DBF, DB, MDB (table). These functions are implemented by the ISAM database interface. To export files of various versions, I downloaded the latest JET4 on the MS website.
Generally, the record set is searched or summarized in access or SQLSERVER, and then a 'record set' is generated, which can be displayed in the GRID or exported to the disk. Below we can export Xls, DBF, DB, MDB (table). These functions are implemented by the ISAM database interface. To export files of various versions, I downloaded the latest JET4 on the MS website.
It is generally searched in access or SQLSERVER, or summarized, and then a 'record set' is generated and can be displayed in the GRID or the record set
ExportTo the disk.
You canExportXls, DBF, DB, MDB (table). These functions are implemented by the ISAM database interfaceExportFor various versions of files, I downloaded the latest JET4 and mdac6. The former is used for desktop databases such as ACCESS and FOXPRO components, and the latter is to implement the new version of ADO components. In:
Http://download.microsoft.com/download/access2000/SP/4.0/NT5/EN-US/Jet40SP5_W2K.exe
Http://download.microsoft.com/download/dasdk/install/2.60.6526.3/WIN98Me/CN/mdac_typ.exe
These are standard SQLExportStatement:
Select * into [office/9.shtml 'target = '_ blank' class = 'Article'> Excel8.0; database =ExportDirectory].ExportTable name from table
Select * into [FoxPro2.6; database =ExportDirectory].ExportTable name from table
Select * into [FoxPro2.5; database = same as above].ExportTable name from table
Select * into [dBaseIII; database = same as above].ExportTable name from table
Select * into [Paradox4.X; database = same as above].ExportTable name from table
Select * into [; database = C: \ temp \ xxx. mdb].ExportTable name from table
The following program uses variables to replace a part of custom file names.
Http://go.163.com /~ Chunpeng/project/export.jpg
Http://go.163.com /~ Click chunpeng/project/Export.zip to download the original program file.
'Reference the ADODB Class Library first.
Dimexico port_str, mdbTableAsString
DimrsExportAsNewADODB. Recordset
DimconnAsNewADODB. Connection
PrivateSubClose_cmd_Click ()
UnloadMe
EndSub
PrivateSubEXport_cmd_Click ()
DimmyPath, myStrAsString, myPosAsInteger
* Processes the selected tableExport
WithDialog1
IfmyOption (2). valuettings
. FilterIndex = 1
. ShowSave
MyStr = StrReverse (. FileName) 'string reverse
MyPos = InStr (myStr, "\") 'in the anti-string, find the first \ position starting from the left
OnErrorGoTomyError ': the FILENAME is empty and the MID error occurs.
MyPath = StrReverse (Mid (myStr, myPos) 'to retrieve the Directory and restore it.
MyStr = StrReverse (Left (myStr, myPos-1) 'get the file name
Export_Str = "select * into [dBaseIII; database =" & myPath & "]." & myStr & "fromCustomers"
. DefaultExt = "*. DBF"
ElseIfmyOption (3). valuettings
MdbTable = InputBox ("please giveExportTo determine the table name of the MDB File ")
. FilterIndex = 2
. ShowSave
Export_Str = "select * into [; database =" &. FileName & "]." & mdbTable & "fromCustomers"
. DefaultExt = "*. MDB"
ElseIfmyOption (4). valuettings
. FilterIndex = 3
. ShowSave
Export_Str = "select * into [Excel8.0; database =" &. FileName & "]. CustomersfromCustomers"
. DefaultExt = "*. XLS"
ElseIfmyOption (5). valuettings
. FilterIndex = 4
. ShowSave
MyStr = StrReverse (. FileName) 'string reverse
MyPos = InStr (myStr, "\") 'in the anti-string, find the first \ position starting from the left
OnErrorGoTomyError ': the FILENAME is empty and the MID error occurs.
MyPath = StrReverse (Mid (myStr, myPos) 'to retrieve the Directory and restore it.
MyStr = StrReverse (Left (myStr, myPos-1) 'get the file name
Export_Str = "select * into [Paradox4.X; database =" & myPath & "]." & myStr & "fromCustomers"
. DefaultExt = "*. DB"
EndIf
EndWith
*.
Debug. PrintExport_Str
IfrsExport. State = 1 Then
RsExport. Close
EndIf
IfDir (Dialog1.FileName) <> "" Then
OnErrorGoTomyError prevents users from selecting files
IfDialog1.FilterIndex <> 2 Then
Kill (Dialog1.FileName)
EndIf
RsExport. OpenExport_Str, conn, adOpenStatic, adLockOptimistic
Else
RsExport. OpenExport_Str, conn, adOpenStatic, adLockOptimistic
EndIf
MyError:
ExitSub
EndSub
PrivateSubForm_Load ()
'Connect to the database and open the record set
Conn. CursorLocation = adUseServer
Conn. Open "PROVIDER = Microsoft. Jet. OLEDB.4.0; DataSource =" App. Path "\ NWind. mdb ;"
RsExport. Open "select * fromCustomers", conn, adOpenStatic, adLockOptimistic
SetGrid1.DataSource = rsExport
'Initialize the conversation basket
WithDialog1
. Filter = "FoxBase/FoxPro (*. DBF )*. DBF Access8.0 (*. MDB )*. MDB Excel8.0 (*. XLS )*. XLS Paradox4.x (*. DB )*. DB"
. DialogTitle ="ExportThe file is"
. CancelError = False
EndWith
EndSub
->