<% '======================================================================================================================= ' DB HELPERS ' Parameterized query/execute on the shared DAL connection. Parameters are built with the typed helpers below: ' Db_Query "SELECT ... WHERE id = ?", Array(Db_PI(5)) '======================================================================================================================= Function Db_PS(v) If IsNull(v) Then Db_PS = Array(202, Null) ElseIf Len(v & "") = 0 Then Db_PS = Array(202, Null) Else Db_PS = Array(202, CStr(v)) End If End Function Function Db_PI(v) If IsNull(v) Or IsEmpty(v) Then Db_PI = Array(3, Null) ElseIf IsNumeric(v) Then Db_PI = Array(3, CLng(v)) Else Db_PI = Array(3, Null) End If End Function Function Db_PD(v) If IsNull(v) Or IsEmpty(v) Then Db_PD = Array(7, Null) ElseIf IsDate(v) Then Db_PD = Array(7, CDate(v)) Else Db_PD = Array(7, Null) End If End Function Function Db_Command(sql, params) Dim cmd, i, p Set cmd = Server.CreateObject("ADODB.Command") Set cmd.ActiveConnection = DAL().Connection cmd.CommandType = 1 cmd.CommandText = sql For i = 0 To UBound(params) p = params(i) If p(0) = 202 Then If IsNull(p(1)) Then cmd.Parameters.Append cmd.CreateParameter(, 202, 1, 1, Null) ElseIf Len(p(1)) > 255 Then cmd.Parameters.Append cmd.CreateParameter(, 203, 1, Len(p(1)), p(1)) Else cmd.Parameters.Append cmd.CreateParameter(, 202, 1, Len(p(1)), p(1)) End If Else cmd.Parameters.Append cmd.CreateParameter(, p(0), 1, , p(1)) End If Next Set Db_Command = cmd End Function Function Db_Query(sql, params) Set Db_Query = Db_Command(sql, params).Execute End Function Sub Db_Exec(sql, params) Db_Command(sql, params).Execute , , 128 End Sub %>