Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I have found your site brilliant. What makes it good are the people that contribute to the site..."

Geography

Where in the world do Tek-Tips members come from?

VBScript issue on Windows Sever 2008

dbaanalystman (MIS)
18 Jun 12 10:01
We have a a vbscript that runs perfectly on a Windows Server 2003 machine. We recently moved to a Windows 2008 machine and we can't get it to run properly. We can connect to Active Directory, but I believe our Database connection is faulty. Has anything changed in the wscript or database connection string that would cause a problem??

Thanks.

Script is listed below:



DESCRIPTION: This script sends an email to the appropriate manager of the submitting matrix analyst.
' The script identifies budget transfers that have not bee approved by the manager and
' sends the manager an email each day the transfers have not been approved.


On Error Resume Next

' Setup Oracle connection
Set dbSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = dbSession.OpenDatabase("fcsdev","fcs/redpuppy1", 0)

'Get Matrix employee number

sqlstr = "select distinct(matrix_nbr)as empnum "_
& "from budget_xfers_mo "_
& "where FIN_MGMT_APPR <> 1 "_
& "or fin_mgmt_appr is null"

Wscript.Echo(sqlstr)

set oraData = OraDatabase.CreateDynaset(sqlstr,0)

if oraData.Recordcount > 0 then
adataArray = oraData.GetRows()


Wscript.Echo(adataArray(0,row))


For row = 0 to Ubound(adataArray,2)

Wscript.Echo(adataArray(0,0))

' Get Managers Empnm and Matrix name
errtype = ""
strSub = "uid=" & CLng(adataArray(0,row)) & ",ou=people,o=fcx,c=us"
ADsPath = "LDAP://directory.fcx.com:389/" & strSub

Set oObjSec = GetObject(ADsPath)

empnum = oObjSec.Get("uid")
realname = oObjSec.Get("givenName") & " " & oObjSec.Get("sn")
mgrenbr = parseMgr(oObjSec.Get("manager"))

Wscript.Echo(empnum & " " & mgrenbr)

' Get Managers email address
errtype = ""
strSub = "uid=" & CLng(mgrenbr) & ",ou=people,o=fcx,c=us"
ADsPath = "LDAP://directory.fcx.com:389/" & strSub

Wscript.Echo(strSub)

Set oObjSec = GetObject(ADsPath)

mgremailaddr = oObjSec.Get("mail")


'Wscript.Echo(mgremailaddr)

'Send email notification to finance manager
Set objEmail = CreateObject("CDO.Message")
objEmail.To = sample@email.com 'matemail
objEmail.Cc = "boss@email.com" 'matemail
objEmail.From = "server@email.com"
objEmail.Subject = "Budget Transfer submitted and ready for review/approval"
strbody = "<html><head><body>"
strbody = strbody & "A budget transfer has been submitted by " & realname & " for your approval.<br><br>"
strbody = strbody & "</body></head></html>"
objEmail.HTMLbody = strbody
objEmail.Send
set objEmail = nothing

'objEmail.To = sample@email.com 'matemail

Next

end if



' Close and destroy objects created by this script
'
oraData.close
OraDatabase.close
'
' Reset all Oracle objects
'
set oraData = nothing
set OraDatabase = nothing
set dbsession = nothing

function parseMgr(instr)
outstr = ""
start = 5
incr = 0
while mid(instr,start+incr,1) >= "0" and mid(instr,start+incr,1) <= "9"
outstr = outstr & mid(instr,start+incr,1)
incr = incr + 1
wend

parseMgr = outstr


end function




PHV (MIS)
18 Jun 12 10:29
To discover what happens, comment out the On Error Resume Next instruction.

Hope This Helps, PH.
FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close