VBA/Excel/Access/Word/Access/Recordset Convert — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 16:33, 26 мая 2010
Converting the Recordset to a String
Sub GetRecords_AsString()
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim varRst As Variant
Dim myFileSystemObject As Object
Dim myFile As Object
Set conn = CurrentProject.Connection
Set rst = New ADODB.Recordset
rst.Open "SELECT EmployeeId, LastName ,FirstName as FullName FROM Employees", _
conn, adOpenForwardOnly, adLockReadOnly, adCmdText
If Not rst.EOF Then
varRst = rst.GetString(adClipString, , vbTab, vbCrLf)
Debug.Print varRst
End If
Set myFileSystemObject = CreateObject("Scripting.FileSystemObject")
Set myFile = myFileSystemObject.CreateTextFile(CurrentProject.Path & _
"\RstString.txt", True)
myFile.WriteLine varRst
myFile.Close
Set myFileSystemObject = Nothing
rst.Close
Set rst = Nothing
conn.Close
Set conn = Nothing
End Sub