Custom form connecting to SQL Server

C

Chad

I am having an issue with Outlook and interfacing with a
db. I am using Outlook with our PTO (Personal Time Off)
requests. When an employee submits a PTO it goes to thier
manager. If a manager approves the request I have the
connection to a db that adds the request and then sends
the response. Sometimes (1 of 10) the response is sent
while nothing is entered in the db. When I try to
replicate the error on those machines I cannot. Any
tips/suggestions to make this more reliable?

On Error Resume Next
If strApproval = "Approved" then
myItem.To = strName & ";HRPTO;" & Application.GetNameSpace
("MAPI").CurrentUser

'Code to connect to the db
Set rs = CreateObject("ADODB.Recordset")
Set cn = CreateObject("ADODB.Connection")

'Open a connection w/o using a Data Source Name (DSN)
cn.ConnectionString = "driver={SQL Server};" & _
"server=MNCORPCLIENT1;uid=sa;pwd=Rally%
67CHEV;database=HighJumpers"
cn.Open
strEmployee_ID = item.userproperties.find("EmployeeID")
strStartDate = item.userproperties.find("First Day")
strEndDate = item.userproperties.find("Return Day")
strReason = Item.Body
strComments = item.userproperties.find("MGR Comment")
strNbrDays = ActDays
If item.userproperties.find("UnpaidPTo") = True Then
strUnpaidPTO = "Y"
Else
strUnpaidPTO = "N"
End If
strApprovedBy = item.userproperties.find("MGR Name")

strSQL = "INSERT INTO PTO (Employee_ID, StartDate,
EndDate, NbrDays, Reason, MgrComments, Type, ApprovedBy,
UnpaidPTO, AddDate) VALUES (" & strEmployee_ID & ", '" &
strStartDate & "', '" & strEndDate & "', " & strNbrDays
& ", '" & strReason & "', '" & strComments & "', 'P', '" &
strApprovedBy & "', '" & strUnpaidPTO & "', '" & Now()
& "')"
cn.Execute strSQL
 
Top