<% ' Tom Wishon Golf Technology ' This page calls SQL Server stored procedure RecommendShaft to make shaft recommendations. ' This page is intended to be integrated with WishonGolf.com, which is a PHP site. With Chris Nichols ' approval, I implemented this page in ASP, which has better error reporting and error trapping. ' ' Author: Donald Scott ' Moutain Sage Software ' DonScott@mss01.com ' (970) 382-0811 ' ' Date: 04/16/2010 ' Option Explicit '---- These constants are used ADODB. '---- CursorTypeEnum Values -------- Public Const adOpenForwardOnly = 0 Public Const adOpenKeyset = 1 Public Const adOpenDynamic = 2 Public Const adOpenStatic = 3 '---- LockTypeEnum Values ------- Public Const adLockReadOnly = 1 Public Const adLockPessimistic = 2 Public Const adLockOptimistic = 3 Public Const adLockBatchOptimistic = 4 '---- CommandTypeEnum Values ------- Public Const adCmdText = &H1 Public Const adCmdTable = &H2 Public Const adCmdStoredProc = &H4 '---- ExecuteOptionEnum ------- Public Const adAsyncExecute = 16 Public Const adAsyncFetch = 32 Public Const adAsyncFetchNonBlocking = 64 Public Const adExecuteNoRecords = 128 Public Const adExecuteStream = 1024 '---- DataTypeEnum Values -------------- Public Const adChar = 129 Public Const adCurrency = 6 Public Const adDecimal = 14 Public Const adDouble = 5 Public Const adInteger = 3 Public Const adSmallInt = 2 Public Const adVarChar = 200 '---- ParameterDirectionEnum Values -------------- Public Const adParamInput = 1 Public Const adParamInputOutput = 3 Public Const adParamOutput = 2 Public Const adParamReturnValue = 4 Public Const adParamUnknown = 0 '---- Application constants ---------- Public Const constNBSP = " " '----- Application Variables ------------- Dim blnDevMode Dim blnFirstLoad Dim cmdRecommendShaft Dim cnnADO Dim lngRowsAffected Dim rstProduct Dim strDiag Dim strErrMsg Dim strSelectDSTe1 Dim strSelectDSTe2 Dim strSelectDSTe3 Dim strSelectDSTr1 Dim strSelectDSTr2 Dim strSelectDSTr3 Dim strSelectPS1 Dim strSelectPS2 Dim strSelectPS3 Dim strSelectWR1 Dim strSelectWR2 Dim strSelectWR3 Dim strSql Dim strX ' These variables correspond to the parameters on the stored proc. Dim intDownswingTempo Dim intDownswingTransistion' Dim intErrNum Dim intIronSwingSpeed Dim intPhysicalStrength Dim intWoodSwingSpeed Dim intWristRelease Dim strRecomGraphiteIronShaft Dim decRecomGraphiteIronTipTrim Dim strRecomHybridShaft Dim decRecomHybridTipTrim Dim strRecomSteelIronShaft Dim decRecomSteelIronTipTrim Dim strRecomWoodShaft Dim decRecomWoodTipTrim '----- General Functions --------------------------------- Public Function appCInt(objValue) ' Convert the specified value to integer; to 0 if it's not numeric. appCInt = 0 If IsNumeric(objValue) Then appCInt = CInt(objValue) End If End Function Private Sub AppendError(strMsg) If Len(strMsg) > 0 Then strErrMsg = strErrMsg & strMsg & vbNewLine End If End Sub Set cnnADO = Server.CreateObject("ADODB.Connection") Set rstProduct = Server.CreateObject("ADODB.Recordset") %> Tom Wishon Golf Technologies - S2S Shaft Fitting System <% blnDevMode = True ' Assign the output parameter variables that will be passed to the stored procedure. strRecomGraphiteIronShaft = "" decRecomGraphiteIronTipTrim = 0 strRecomHybridShaft = "" decRecomHybridTipTrim = 0 strRecomSteelIronShaft = "" decRecomSteelIronTipTrim = 0 strRecomWoodShaft = "" decRecomWoodTipTrim = 0 strDiag = "" strErrMsg = "" Err.Clear On Error Resume Next cnnADO.Open "Driver={SQL Server};server=localhost;Database=shaftfit_twgt;UID=shaftfit_admin;PWD=kUp93aZu;" 'MLS721!@! intErrNum = Err.Number If intErrNum <> 0 Then If blnDevMode Then AppendError Err.Description Else AppendError "Unable to connect to database" ' We don't want to show the user "Login failed for user 'staftfit'". End If End If On Error GoTo 0 ' Read form values when this form posts back to itself. intIronSwingSpeed = appCInt(Request.Form("txtIronSwingSpeed")) ' Cast to integer. intWoodSwingSpeed = appCInt(Request.Form("txtWoodSwingSpeed")) ' 04/15/10. I did a bit of testing today I decided this is an adequate way to determine if this is the first time ' this page is being loaded. Henceforth, ddlDownswingTransistion should alwasy have a value. strX = RTrim(Request.Form("ddlDownswingTransistion")) blnFirstLoad = (Len(strX) = 0) ' Downswing Tempo. intDownswingTempo = appCInt(Request.Form("ddlDownswingTempo")) Select Case intDownswingTempo Case 2 strSelectDSTe2 = "selected" Case 3 strSelectDSTe3 = "selected" Case Else ' This means this is the first time this page has been loaded. intDownswingTempo = 1 strSelectDSTe1 = "selected" End Select ' Downswing Transistion. intDownswingTransistion = appCInt(Request.Form("ddlDownswingTransistion")) Select Case intDownswingTransistion Case 2 strSelectDSTr2 = "selected" Case 3 strSelectDSTr3 = "selected" Case Else intDownswingTransistion = 1 strSelectDSTr1 = "selected" End Select ' Physical Strength. intPhysicalStrength = appCInt(Request.Form("ddlPhysicalStrength")) Select Case intPhysicalStrength Case 2 strSelectPS2 = "selected" Case 3 strSelectPS3 = "selected" Case Else intPhysicalStrength = 1 strSelectPS1 = "selected" End Select ' Wrist Cock Release. intWristRelease = appCInt(Request.Form("ddlWristRelease")) Select Case intWristRelease Case 2 strSelectWR2 = "selected" Case 3 strSelectWR3 = "selected" Case Else intWristRelease = 1 strSelectWR1 = "selected" End Select If blnFirstLoad Or (Len(strErrMsg) > 0) Then ' When this page is first requested there is no need to call the stored proc. Else ' Prepare and call the stored procedure. Set cmdRecommendShaft = Server.CreateObject("ADODB.Command") With cmdRecommendShaft .ActiveConnection = cnnADO .CommandText = "RecommendShaft" ' This is the procedure name. .CommandType = adCmdStoredProc ' Set parameter = command.CreateParameter (Name, Type, Direction, Size, Value) .Parameters.Append .CreateParameter("@smallintWoodSwingSpeed", adSmallInt, adParamInput, , intWoodSwingSpeed) .Parameters.Append .CreateParameter("@smallintIronSwingSpeed", adSmallInt, adParamInput, , intIronSwingSpeed) .Parameters.Append .CreateParameter("@smallintDownswingTransistion", adSmallInt, adParamInput, , intDownswingTransistion) .Parameters.Append .CreateParameter("@smallintDownswingTempo", adSmallInt, adParamInput, , intDownswingTempo) .Parameters.Append .CreateParameter("@smallintWristRelease", adSmallInt, adParamInput, , intWristRelease) .Parameters.Append .CreateParameter("@smallintPhysicalStrength", adSmallInt, adParamInput, , intPhysicalStrength) .Parameters.Append .CreateParameter("@strRecomGraphiteIronShaft", adVarChar, adParamOutput, 100, strRecomGraphiteIronShaft) .Parameters.Append .CreateParameter("@decRecomGraphiteIronTipTrim", adDecimal, adParamOutput, , decRecomGraphiteIronTipTrim) .Parameters("@decRecomGraphiteIronTipTrim").NumericScale = 2 .Parameters("@decRecomGraphiteIronTipTrim").Precision = 6 .Parameters.Append .CreateParameter("@strRecomHybridShaft", adVarChar, adParamOutput, 100, strRecomHybridShaft) .Parameters.Append .CreateParameter("@decRecomHybridTipTrim", adDecimal, adParamOutput, , decRecomHybridTipTrim) .Parameters("@decRecomHybridTipTrim").NumericScale = 2 .Parameters("@decRecomHybridTipTrim").Precision = 6 .Parameters.Append .CreateParameter("@strRecomSteelIronShaft", adVarChar, adParamOutput, 100, strRecomSteelIronShaft) .Parameters.Append .CreateParameter("@decRecomSteelIronTipTrim", adDecimal, adParamOutput, , decRecomSteelIronTipTrim) .Parameters("@decRecomSteelIronTipTrim").NumericScale = 2 .Parameters("@decRecomSteelIronTipTrim").Precision = 6 .Parameters.Append .CreateParameter("@strRecomWoodShaft", adVarChar, adParamOutput, 100, strRecomWoodShaft) .Parameters.Append .CreateParameter("@decRecomWoodTipTrim", adDecimal, adParamOutput, , decRecomWoodTipTrim) .Parameters("@decRecomWoodTipTrim").NumericScale = 2 .Parameters("@decRecomWoodTipTrim").Precision = 6 .Parameters.Append .CreateParameter("@strErrMsg", adVarChar, adParamOutput, 250, strErrMsg) ' Execute the proc and trap any error it throws. Err.Clear On Error Resume Next .Execute lngRowsAffected, , adExecuteNoRecords intErrNum = Err.Number If intErrNum <> 0 Then If blnDevMode Then AppendError Err.Description Else AppendError "Unable to connect to execute procedure" End If End If On Error GoTo 0 ' Extract the output parameters. strRecomGraphiteIronShaft = .Parameters("@strRecomGraphiteIronShaft") decRecomGraphiteIronTipTrim = .Parameters("@decRecomGraphiteIronTipTrim") strRecomHybridShaft = .Parameters("@strRecomHybridShaft") decRecomHybridTipTrim = .Parameters("@decRecomHybridTipTrim") strRecomSteelIronShaft = .Parameters("@strRecomSteelIronShaft") decRecomSteelIronTipTrim = .Parameters("@decRecomSteelIronTipTrim") strRecomWoodShaft = .Parameters("@strRecomWoodShaft") decRecomWoodTipTrim = .Parameters("@decRecomWoodTipTrim") AppendError .Parameters("@strErrMsg") End With cnnADO.Close End If ' Append a non-breaking space to the shaft recommendation, which will prevent the cells from ' collapsing when they are unassigned. strRecomGraphiteIronShaft = strRecomGraphiteIronShaft & constNBSP strRecomHybridShaft = strRecomHybridShaft & constNBSP strRecomSteelIronShaft = strRecomSteelIronShaft & constNBSP strRecomWoodShaft = strRecomWoodShaft & constNBSP %>
S2S Shaft Fitting
Golfer Driver/3 wood Clubhead Speed
(enter speed from 50 – 120mph)
 mph Golfer 5- / 6-iron Clubhead Speed
(enter speed from 40 – 90mph)
 mph
Golfer Downswing Transition Rating Golfer Downswing Tempo Rating
Golfer Wrist-Cock Release Position Golfer Physical Strength Rating
S2S Wood Shaft Recommendation Adjust Tip Trim
<% =strRecomWoodShaft %> <% If (blnFirstLoad) Or (Len(strRecomWoodShaft) = 0) Then ' Suppress Else Response.Write decRecomWoodTipTrim & chr(34) End If %>
S2S Iron Shaft (Graphite) Recommendation Adjust Tip Trim
<% =strRecomGraphiteIronShaft %> <% If (blnFirstLoad) Or (Len(strRecomGraphiteIronShaft) = 0) Then ' Suppress Else Response.Write decRecomGraphiteIronTipTrim & chr(34) End If %>
S2S Iron Shaft (Steel) Adjust Tip Trim
<% Response.Write strRecomSteelIronShaft %> <% If (blnFirstLoad) Or (Len(strRecomSteelIronShaft) = 0) Or (strRecomSteelIronShaft = "No Recommendation") Then ' Suppress Else Response.Write decRecomSteelIronTipTrim & chr(34) End If %>
S2S Hybrid Shaft Recommendation
Adjust Tip Trim
<% Response.Write strRecomHybridShaft %> <% If (blnFirstLoad) Or (Len(strRecomHybridShaft) = 0) Then ' Suppress Else Response.Write decRecomHybridTipTrim & chr(34) End If %>
<% If Len(strErrMsg) = 0 Then ' No error message? Claim a bit of space so the layout won't change much ' when there is. strErrMsg = constNBSP & vbNewLine & constNBSP End If strErrMsg = Replace(strErrMsg, vbNewLine, "
") Response.Write strErrMsg %>