Advertisement
Advertisement
| 09.30.2008 at 08:17AM PDT, ID: 23774913 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: |
Public Sub ExecuteQry(strQry, intCommandType, arrParamValues, arrParamDataTypes, arrReturn)
Set objConn = CreateObject("Adodb.Connection")
objConn.Open strConnString
Set objCmd = CreateObject("ADODB.Command")
objCmd.CommandText = strQry
objCmd.CommandType = intCommandType
If IsArray(arrParamValues) And IsArray(arrParamDataTypes) Then
If UBound(arrParamValues) = UBound(arrParamDataTypes) Then
For i = 0 To UBound(arrParamValues)
Select Case arrParamDataTypes(i)
Case 2 'Small Integer
strDataLength = 2
Case 3 'Integer
strDataLength = 4
Case 4 'Single
strDataLength = 4
Case 5 'Float
strDataLength = 8
Case 6 'Currency
strDataLength = 8
Case 7 'Date
strDataLength = 8
Case 11 'Bit
strDataLength = 1
Case 14 'Decimal
strDataLength = 9
Case 72 'GUID
strDataLength = 16
Case 128 'Binary
strDataLength = 50
Case 129 'Char
If Not ReqValue(arrParamValues(i)) Then
strDataLength = 1
Else
strDataLength = Len(arrParamValues(i))
End If
Case 200 'VarChar
If Not ReqValue(arrParamValues(i)) Then
strDataLength = 1
Else
strDataLength = Len(arrParamValues(i))
End If
Case 203 'NText
If Not ReqValue(arrParamValues(i)) Then
strDataLength = 1
Else
strDataLength = Len(arrParamValues(i))
End If
Case 204 'VarBinary
strDataLength = 50
Case Else 'Hmm...guess
If Not ReqValue(arrParamValues(i)) Then
strDataLength = 1
Else
strDataLength = Len(arrParamValues(i))
End If
End Select
If arrParamDataTypes(i) = 14 Then
Set p = objCmd.CreateParameter(, CLng(arrParamDataTypes(i)), , CLng(strDataLength), InputCleaner(arrParamValues(i)))
p.NumericScale = 2
p.Precision = 10
objCmd.Parameters.Append p
Else
objCmd.Parameters.Append(objCmd.CreateParameter(, CLng(arrParamDataTypes(i)), , CLng(strDataLength), InputCleaner(arrParamValues(i))))
End If
Next
i = Null
Else
strMessage = "Your values and data type arrays need to be the same length."
End If
End If
Set objCmd.ActiveConnection = objConn
If InStr(1, UCase(strQry), "SELECT") > 0 Then
Set objRS = objCmd.Execute()
If Not(objRS.EOF) Then
arrReturn = objRS.GetRows()
Else
strMessage = "There are no records."
Exit Sub
End If
Set objRS = Nothing
Exit Sub
ElseIf InStr(1, UCase(strQry), "INSERT") > 0 Then
If InStr(1, UCase(strQry), "@@IDENTITY") > 0 Or InStr(1, UCase(strQry), "NEWID()") > 0 Then
Set objRS = objCmd.Execute()
If Not(objRS.EOF) Then
arrReturn = objRS(0)
End If
set objRS = Nothing
Else
objCmd.Execute()
strMessage = "Your command has been executed."
End If
ElseIf (InStr(1,UCase(strQry),"DELETE") > 0 Or InStr(1, UCase(strQry), "UPDATE") > 0 Or Left(UCase(strQry),2) = "SP") then
objCmd.Execute()
strMessage = "Your command has been executed."
End If
Set objCmd.ActiveConnection = Nothing
Set objCmd = Nothing
objConn.Close()
Set objConn = Nothing
End Sub
|