呵,我会呀,会呀。 程序如下: Private Sub Command1_Click() Call Crdata2Text End Sub ________________________________________________ Public Function Crdata2Text() As Boolean 'Open database using the ODBC Direct method Dim DB2TEXT As DataBase Dim RS2TEXT As RecordSet Set DB2TEXT = DBEngine.Workspaces(0).OpenDtaBase("EXAMPLE.mdb") Set RS2TEXT = DB2TEXT.OpenRecordSet("CRDATA") Dim iTotalRecords As Integer Dim sFileToExport As String Dim iFileNum As Integer Dim iIndx As Integer Dim iNumberOfFields As Integer 'Open TEXT file to write, if not found, create one sFileToExport = "TEXT.txt" iFileNum = FreeFile() Open sFileToExport For Output As #iFileNum iNumberOfFields = RS2TEXT.Fields.Count - 1 'Start Transferring... RS2TEXT.MoveFirst Do Until RS2TEXT.EOF iTotalRecords = iTotalRecords + 1 For iIndx = 0 To iNumberOfFields If (IsNull(RS2TEXT.Fields(iIndx))) Then Print #iFileNum, ","; Else If indx = iNumberOfFields Then Print #iFileNum, Trim$(CStr(RS2TEXT.Fields(iIndx))); Else Print #iFileNum, Trim$(CStr(RS2TEXT.Fields(iIndx))); ","; End If End If Next Print #iFileNum, RS2TEXT.MoveNext DoEvents Loop Close #iFileNum 'Delete Data in the CRDATA table Do Until RS2TEXT.EOF RS2TEXT.MoveFirst RS2TEXT.Delete RS2TEXT.MoveNext Loop 'Don't forget to close the mdb database RS2TEXT.Close DB2TEXT.Close End Function
用ADODim Conn as new adodb.connection Dim Rs as new adodb.RecordSet Conn.open strconn,... SqlStr="Select * from urtable" Rs.Open SqlStr,Conn,... Str=Rs.GetString()这里参数可选字段与记录的分割符 Open UrFile For Output As #1 Print #1,Str Close #1 Rs.Close Set Rs= Nothing Set Conn=Nothing
3、用管理工具,打开一个表,然后CTRL+A选中所有的记录,然后复制、粘贴到记事本上,存盘,OK!
:-)
SQL->导出数据向导->目的选择文本文件
access->导出-> 保存类型为文本文件
程序如下:
Private Sub Command1_Click()
Call Crdata2Text
End Sub
________________________________________________
Public Function Crdata2Text() As Boolean
'Open database using the ODBC Direct method
Dim DB2TEXT As DataBase
Dim RS2TEXT As RecordSet
Set DB2TEXT = DBEngine.Workspaces(0).OpenDtaBase("EXAMPLE.mdb")
Set RS2TEXT = DB2TEXT.OpenRecordSet("CRDATA")
Dim iTotalRecords As Integer
Dim sFileToExport As String
Dim iFileNum As Integer
Dim iIndx As Integer
Dim iNumberOfFields As Integer
'Open TEXT file to write, if not found, create one
sFileToExport = "TEXT.txt"
iFileNum = FreeFile()
Open sFileToExport For Output As #iFileNum
iNumberOfFields = RS2TEXT.Fields.Count - 1
'Start Transferring...
RS2TEXT.MoveFirst
Do Until RS2TEXT.EOF
iTotalRecords = iTotalRecords + 1
For iIndx = 0 To iNumberOfFields
If (IsNull(RS2TEXT.Fields(iIndx))) Then
Print #iFileNum, ",";
Else
If indx = iNumberOfFields Then
Print #iFileNum, Trim$(CStr(RS2TEXT.Fields(iIndx)));
Else
Print #iFileNum, Trim$(CStr(RS2TEXT.Fields(iIndx))); ",";
End If
End If
Next
Print #iFileNum,
RS2TEXT.MoveNext
DoEvents
Loop
Close #iFileNum
'Delete Data in the CRDATA table
Do Until RS2TEXT.EOF
RS2TEXT.MoveFirst
RS2TEXT.Delete
RS2TEXT.MoveNext
Loop
'Don't forget to close the mdb database
RS2TEXT.Close
DB2TEXT.Close
End Function
Dim Rs as new adodb.RecordSet
Conn.open strconn,...
SqlStr="Select * from urtable"
Rs.Open SqlStr,Conn,...
Str=Rs.GetString()这里参数可选字段与记录的分割符
Open UrFile For Output As #1
Print #1,Str
Close #1
Rs.Close
Set Rs= Nothing
Set Conn=Nothing
TO:jingxiaoping(恋爱温度) 你的是不是太烦了???????