dbTalk Databases Forums  

VBScript Runtime Error: Object Required

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss VBScript Runtime Error: Object Required in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Crazy about SQL Server
 
Posts: n/a

Default VBScript Runtime Error: Object Required - 04-19-2005 , 08:26 AM






I am very new to DTS and ActiveX scripts. I had a package that was running
without incident until recently. I honestly don't know if Network Operations
changed anything on the server. When executing the below ActiveX script via
DTS, I receive the following error message:

Error Code: 0
Error Source= Microsoft VBScript runtime error
Error Description: Object required: 'RS'

Error on Line 42

Here is my ActiveX script in its entirety:
Option Explicit

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

Dim ObjPackage
Dim ObjData
Dim sAttachmentList
Dim RS
Dim oStep
Dim oPackage
Dim Mail
Dim sAddressList
Dim sAddressArray
Dim sAddressLoop
Dim sAttachmentArray
Dim sAttachment
Dim ErrorCount
Dim sFromName

' Set the Package Object Reference
Set oPackage = DTSGlobalVariables.Parent

'Create an ADO recordset
Set RS = CreateObject("ADODB.Recordset")

'Set the RecordSet to the value of the gvEmailList global
'var set in the previous DTS Step
Set RS = DTSGlobalVariables("gvEmailList").Value

'Create a MailSender Object
Set Mail = CreateObject("Persits.MailSender")

'Set the SMTP Host
Mail.Host = "mailrelay.company.net"

ErrorCount = 0

'Each Item in the resultset is an Email to be sent. Loop through the
result set and send the emails.
DO WHILE NOT RS.EOF

IF ErrorCount > 10 THEN
EXIT DO
END IF

'Set some globals for use in post processing
DTSGlobalVariables("gvScheduledEmailId").Value =
RS.Fields("ScheduledEmailId").value
DTSGlobalVariables("gvScheduledEmailTypeId").Value =
RS.Fields("ScheduledEmailTypeId").value

'Parse the Address List and add an addres for each recipient
sAddressList = RS.Fields("ToAddress").Value
sAddressArray = Split(sAddressList,";")
FOR EACH sAddressLoop IN sAddressArray
Mail.AddAddress sAddressLoop
NEXT

'Set parameters for the email

Mail.From = RS.Fields("FromAddress").Value

'msgbox RS.Fields("FromAddress").Value

sFromName=Trim(RS.Fields("FromName") & "")
IF Len(sFromName) > 0 Then
Mail.FromName = RS.Fields("FromName").Value
END If

Mail.Subject = RS.Fields("Subject").Value
Mail.Body = RS.Fields("Body").Value

' Grab the attachment List
sAttachmentList = Trim(RS.Fields("AttachmentList") & "")

If Len(sAttachmentList) > 0 Then
sAttachmentArray = Split(sAttachmentList,",")
FOR EACH sAttachment IN sAttachmentArray
Mail.AddAttachment sAttachment
NEXT
End If

'Now Send the Email. Check for errors and if it succeeds, execute
the appropriate task
ON ERROR RESUME NEXT
Mail.Send
IF Err.Number <> 0 Then 'Error occured
ErrorCount = ErrorCount + 1
DTSGlobalVariables("gvErrorSource").Value = Err.Source
DTSGlobalVariables("gvErrorNumber").Value = Err.Number
DTSGlobalVariables("gvErrorDescription").Value = Err.Description
Set oStep = oPackage.Steps("DTSStep_DTSExecuteSQLTask_4")
oStep.Execute
Set oStep = oPackage.Steps("DTSStep_DTSActiveScriptTask_2")
oStep.Execute

ELSE
Set oStep = oPackage.Steps("DTSStep_DTSExecuteSQLTask_5")
oStep.Execute
Set oStep = oPackage.Steps("DTSStep_DTSExecuteSQLTask_2")
oStep.Execute
END IF

RS.MoveNext

'Reset the Mail Object
Mail.Reset

LOOP

Set Mail = Nothing
Set RS = nothing

Main = DTSTaskExecResult_Success

End Function

**********************
I believe it is failing at this line: DO WHILE NOT RS.EOF
I tried putting message boxes before this line, but receive the same error
anyway, just a different line number. Can anyone please shed some light? I
don't even know where to begin.

Thank you.

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: VBScript Runtime Error: Object Required - 04-19-2005 , 02:38 PM






Looking at your CREATEOBJECT codes I would have thought this one is the problem

'Create a MailSender Object
Set Mail = CreateObject("Persits.MailSender")

Have they removed it?
Do you need to reregister the dll?



--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - SQL Server 2005 Integration Services.
www.Konesans.com


"Crazy about SQL Server" <CrazyaboutSQLServer (AT) discussions (DOT) microsoft.com> wrote

Quote:
I am very new to DTS and ActiveX scripts. I had a package that was running
without incident until recently. I honestly don't know if Network Operations
changed anything on the server. When executing the below ActiveX script via
DTS, I receive the following error message:

Error Code: 0
Error Source= Microsoft VBScript runtime error
Error Description: Object required: 'RS'

Error on Line 42

Here is my ActiveX script in its entirety:
Option Explicit

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

Dim ObjPackage
Dim ObjData
Dim sAttachmentList
Dim RS
Dim oStep
Dim oPackage
Dim Mail
Dim sAddressList
Dim sAddressArray
Dim sAddressLoop
Dim sAttachmentArray
Dim sAttachment
Dim ErrorCount
Dim sFromName

' Set the Package Object Reference
Set oPackage = DTSGlobalVariables.Parent

'Create an ADO recordset
Set RS = CreateObject("ADODB.Recordset")

'Set the RecordSet to the value of the gvEmailList global
'var set in the previous DTS Step
Set RS = DTSGlobalVariables("gvEmailList").Value

'Create a MailSender Object
Set Mail = CreateObject("Persits.MailSender")

'Set the SMTP Host
Mail.Host = "mailrelay.company.net"

ErrorCount = 0

'Each Item in the resultset is an Email to be sent. Loop through the
result set and send the emails.
DO WHILE NOT RS.EOF

IF ErrorCount > 10 THEN
EXIT DO
END IF

'Set some globals for use in post processing
DTSGlobalVariables("gvScheduledEmailId").Value =
RS.Fields("ScheduledEmailId").value
DTSGlobalVariables("gvScheduledEmailTypeId").Value =
RS.Fields("ScheduledEmailTypeId").value

'Parse the Address List and add an addres for each recipient
sAddressList = RS.Fields("ToAddress").Value
sAddressArray = Split(sAddressList,";")
FOR EACH sAddressLoop IN sAddressArray
Mail.AddAddress sAddressLoop
NEXT

'Set parameters for the email

Mail.From = RS.Fields("FromAddress").Value

'msgbox RS.Fields("FromAddress").Value

sFromName=Trim(RS.Fields("FromName") & "")
IF Len(sFromName) > 0 Then
Mail.FromName = RS.Fields("FromName").Value
END If

Mail.Subject = RS.Fields("Subject").Value
Mail.Body = RS.Fields("Body").Value

' Grab the attachment List
sAttachmentList = Trim(RS.Fields("AttachmentList") & "")

If Len(sAttachmentList) > 0 Then
sAttachmentArray = Split(sAttachmentList,",")
FOR EACH sAttachment IN sAttachmentArray
Mail.AddAttachment sAttachment
NEXT
End If

'Now Send the Email. Check for errors and if it succeeds, execute
the appropriate task
ON ERROR RESUME NEXT
Mail.Send
IF Err.Number <> 0 Then 'Error occured
ErrorCount = ErrorCount + 1
DTSGlobalVariables("gvErrorSource").Value = Err.Source
DTSGlobalVariables("gvErrorNumber").Value = Err.Number
DTSGlobalVariables("gvErrorDescription").Value = Err.Description
Set oStep = oPackage.Steps("DTSStep_DTSExecuteSQLTask_4")
oStep.Execute
Set oStep = oPackage.Steps("DTSStep_DTSActiveScriptTask_2")
oStep.Execute

ELSE
Set oStep = oPackage.Steps("DTSStep_DTSExecuteSQLTask_5")
oStep.Execute
Set oStep = oPackage.Steps("DTSStep_DTSExecuteSQLTask_2")
oStep.Execute
END IF

RS.MoveNext

'Reset the Mail Object
Mail.Reset

LOOP

Set Mail = Nothing
Set RS = nothing

Main = DTSTaskExecResult_Success

End Function

**********************
I believe it is failing at this line: DO WHILE NOT RS.EOF
I tried putting message boxes before this line, but receive the same error
anyway, just a different line number. Can anyone please shed some light? I
don't even know where to begin.

Thank you.



Reply With Quote
Reply




Thread Tools
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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.