I want to read through a text file and then insert the values from those recs into a SQL Server 2000 table using the INSERT stmt.
Here is the text file code.
F = FreeFile
Open "\\sthcepicprod1\imports\ANSI\CCT\CCTPreSort.txt" For Input As F
'Declare recordset settings
Set rsSort = New ADODB.Recordset
With rsSort
Set .ActiveConnection = Nothing
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
'Define recordset fields and properties
With .Fields
.Append "Long1", adChar, 39
.Append "Memno", adChar, 18
.Append "Long2", adChar, 125
.Append "Long3", adChar, 81
.Append "FromDate", adChar, 7
.Append "ThruDate", adChar, 7
.Append "Long4", adChar, 116
.Append "Long5", adChar, 187
End With
.Open
End With
'Write data elements to recordset
Do While Not EOF(F)
Line Input #F, sLine
Long1 = Mid(sLine, 1, 39)
Memno = Mid(sLine, 40, 18)
Long2 = Mid(sLine, 58, 125)
Long3 = Mid(sLine, 183, 81)
FromDate = Mid(sLine, 264, 7)
ThruDate = Mid(sLine, 271, 7)
Long4 = Mid(sLine, 278, 116)
Long5 = Mid(sLine, 394, 187)
Loop
Is there a way to delclare my SQL recordset and in the cmd statement use this text code in the VALUES part. i.e.
WITH sqlcmd
.commandtext "insert into dbo.atable values(Could something from the text code go in here)
If someone could give me an example to get me going in the right path I sure would appreciate it.
Thanks alot,
Bob
Here is the text file code.
F = FreeFile
Open "\\sthcepicprod1\imports\ANSI\CCT\CCTPreSort.txt" For Input As F
'Declare recordset settings
Set rsSort = New ADODB.Recordset
With rsSort
Set .ActiveConnection = Nothing
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
'Define recordset fields and properties
With .Fields
.Append "Long1", adChar, 39
.Append "Memno", adChar, 18
.Append "Long2", adChar, 125
.Append "Long3", adChar, 81
.Append "FromDate", adChar, 7
.Append "ThruDate", adChar, 7
.Append "Long4", adChar, 116
.Append "Long5", adChar, 187
End With
.Open
End With
'Write data elements to recordset
Do While Not EOF(F)
Line Input #F, sLine
Long1 = Mid(sLine, 1, 39)
Memno = Mid(sLine, 40, 18)
Long2 = Mid(sLine, 58, 125)
Long3 = Mid(sLine, 183, 81)
FromDate = Mid(sLine, 264, 7)
ThruDate = Mid(sLine, 271, 7)
Long4 = Mid(sLine, 278, 116)
Long5 = Mid(sLine, 394, 187)
Loop
Is there a way to delclare my SQL recordset and in the cmd statement use this text code in the VALUES part. i.e.
WITH sqlcmd
.commandtext "insert into dbo.atable values(Could something from the text code go in here)
If someone could give me an example to get me going in the right path I sure would appreciate it.
Thanks alot,
Bob