Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > Microsoft Scripting Runtime

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-24-07, 16:27
mustish1 mustish1 is offline
Registered User
 
Join Date: Jul 2006
Posts: 145
Microsoft Scripting Runtime

Hi: I add Project-References Microsoft Scripting Runtime but it still gives me syntax error on that line.

Set OutStream = FSO.CreateTextFile(Source, True)

Private Sub Form_Load()
Export
Main = DTSTaskExecResult_Success
End Sub

Public Sub Export()
Dim DBConn
Dim RS, RCount
Dim FSO, OutStream
Dim I
Dim OutBuff
Dim Source
Dim Str
Dim Destination
Dim DT

Set DBConn = CreateObject("ADODB.Connection")
DBConn.OPEN "Provider=SQLOLEDB; Data Source=OMS0062K\DEVELOPMENT; Initial Catalog=AccountDistribution; User ID=sa"
Set RS = DBConn.Execute("SELECT * FROM tbl_DistList_DEP_duplicate")
Set FSO = CreateObject("Scripting.FileSystemObject")

DT = Now()
DT = Replace(Replace(Replace(DT, ":", ""), " ", "_"), "/", "")
'Source = "\\Usnymel1fs001\MortgageLeads\OMSUL" & DT & ".txt"

If Not RS.EOF Then
Set OutStream = FSO.CreateTextFile(Source, True)
End If

RCount = 0
Do While Not RS.EOF
Str = ""
Str = RS.Fields("Clt_ID") & ","
Str = Str & RS.Fields("cur_bal") & ","
Str = Str & RS.Fields("list_date") & ","
Str = Str & RS.Fields("debtor_id") & ","
Str = Str & RS.Fields("name1") & ","
Str = Str & RS.Fields("worklist") & ","
Str = Str & RS.Fields("duplicate_count") & ","

OutStream.WriteLine Str
RCount = RCount + 1
RS.MoveNext
Loop

Destination = "c:\myfiles\"

If RS.RecordCount > 0 Then
FSO.CopyFile Source, Destination, True
OutStream.Close
End If

Set FSO = Nothing

UpdateDB RS, RCount, DBConn

End Sub

Public Sub UpdateDB(RS, RCount, DBConn)
Dim UpdStr
If RCount > 0 Then
UpdStr = "("
RS.MoveFirst
Do While Not RS.EOF
UpdStr = UpdStr & "'" & RS.Fields("Debtor_ID") & "',"
RS.MoveNext
Loop
If Len(UpdStr) > 2 Then
UpdStr = Left(UpdStr, Len(UpdStr) - 1) & ")"
DBConn.Execute ("Update Mortgage_Leads Set Processed = '1' where debtor_id in " & UpdStr)
End If
End If

DBConn.Close
Set DBConn = Nothing
Set RS = Nothing
End Sub

'Function Main()
' Export
' Main = DTSTaskExecResult_Success
'End Function
Reply With Quote
  #2 (permalink)  
Old 01-24-07, 16:57
RedNeckGeek RedNeckGeek is offline
Village Idiot
 
Join Date: Jul 2003
Location: Michigan
Posts: 1,853
You have the line that populates Source commented out.
__________________
"Gotta go... there's p*rn piling up on the internet" - Gregory House MD
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On