%
Class F_DB
Private O_CONN
Public Property Get C_CONN()
O_CONN = O_CONN
End Property
Public Property Set C_CONN(sContent)
O_CONN = sContent
End Property
Private Sub Class_Initialize()
End Sub
Function ExecuteQueryCol(oConn,aFields,sTable,sCondition)
Dim sQuery
Dim Item
Dim oRS
Dim aReturn
Dim iRowCounter
Dim iColCounter
Dim O_CONN
Set O_CONN = oConn
If sCondition <> "" Then
sCondition = " " & sCondition
End If
aFields = Split(aFields,",")
sQuery = "SELECT "
For Each Item in aFields
sQuery = sQuery & Item
Next
sQuery = sQuery & " FROM " & sTable & sCondition
Set oRS = Server.CreateObject("ADODB.RecordSet")
oRS.Open sQuery, O_CONN, 3,3,1
If oRS.RecordCount > 0 Then
aReturn = oRS.GetRows()
Else
End If
oRS.Close
Set oRS = Nothing
ExecuteQuery = aReturn
End Function
Function ExecuteNonQuery(oConn,sQuery)
oConn.Execute(sQuery)
ExecuteNonQuery = True
End Function
Function ExecuteInsert(oConn,sTable,aFields)
'sQ = "INSERT INTO news ("
' For Each item In aFields
' sQ = sQ & item & ","
' Next
' sQ = TrimR(sQ,1)
' sQ = sQ & ") VALUES ("
' For Each item In aFields
' sQ = sQ & aFields(item) & ","
' Next
' sQ = TrimR(sQ,1)
' sQ = sQ & ")"
' Response.Write(sQ)
sQ = "SELECT TOP 1 * FROM "&sTable
Set oRS = Server.CreateObject("Adodb.RecordSet")
oRS.Open sQ, oConn,3,3,1
oRS.AddNew
For Each Item in aFields
oRS(Item) = aFields(Item)
Next
oRS.Update
oRS.Close
Set oRS = Nothing
Set oRS = oConn.Execute("SELECT @@Identity AS ID")
iID = oRS("ID")
SET oRS = Nothing
ExecuteInsert = iID
End Function
Function GetValue(oConn,sField,sTable,sCondition)
Dim sQuery
Dim Item
Dim oRS
Dim aReturn
Dim iRowCounter
Dim iColCounter
Dim O_CONN
Dim sReturn
sReturn = ""
Set O_CONN = oConn
If sCondition <> "" Then
sCondition = " " & sCondition
End If
sQuery = "SELECT "& sField &" FROM " & sTable & sCondition
Set oRS = Server.CreateObject("ADODB.RecordSet")
If Request.QueryString("showq") = 1 Then
Response.Write("
" & sQuery & "
")
End If
oRS.Open sQuery, O_CONN, 3,3,1
If oRS.RecordCount > 0 Then
Do Until oRS.EOF
sReturn = oRS(sField)
oRS.MoveNext
Loop
Else
End If
oRS.Close
Set oRS = Nothing
GetValue = sReturn
End Function
Function ExecuteQuery(oConn,sQuery)
If Request.QueryString("showq") = 1 Then
Response.Write("" & sQuery & "
")
Response.Write("" & oConn & "
")
End If
Set O_CONN = oConn
'Dim aTemp(999,100)
Dim oRS
Set oRS = Server.CreateObject("Adodb.RecordSet")
oRS.Open sQuery, O_CONN,3,3,1
'Dim iTotal
'iTotal = cInt(oRS.RecordCount)
Dim aTemp
If oRS.RecordCount > 0 Then
aTemp = oRS.GetRows
If Not oRS.EOF Then
iRowCounter = 0
Do Until oRS.EOF
For i = 0 to oRS.Fields.Count - 1
aTemp(iRowCounter,i) = oRS(i)
Next
iRowCounter = iRowCounter + 1
oRS.MoveNext
Loop
Else
End If
Else
aTemp = false
End If
oRS.Close
Set oRS = Nothing
ExecuteQuery = aTemp
End Function
Function GetCount(oConn,sQ)
intCount = 0
Set oRS = Server.CreateObject("Adodb.RecordSet")
oRS.Open sQ, oConn,3,3,1
intCount = oRS.RecordCount
oRS.Close
Set oRS = Nothing
GetCount = intCount
End Function
Function ExecutePageQuery(oConn,sQuery,iPageSize)
intCurrentPage = 0
If Request.QueryString("pg") <> "" Then
intCurrentPage = cInt(Trim(Request.QueryString("pg")))
End If
If Session("showq") = 1 Then
Response.Write("" & sQuery & "
")
Response.Write("" & oConn & "
")
End If
Set O_CONN = oConn
'Dim aTemp(999,100)
Dim oRS
Set oRS = Server.CreateObject("Adodb.RecordSet")
oRS.PageSize = 50
oRS.Open sQuery, O_CONN,3,3,1
oRS.AbsolutePage = intCurrentPage
Response.Write(oRS.RecordCount)
'Dim iTotal
'iTotal = cInt(oRS.RecordCount)
Dim aTemp()
ReDim aTemp(oRS.Fields.Count-1,oRS.RecordCount-1)
If oRS.RecordCount > 0 Then
'aTemp = oRS.GetRows
If Not oRS.EOF Then
iRowCounter = 0
Do Until oRS.EOF
For i = 0 to oRS.Fields.Count - 1
aTemp(i,iRowCounter) = oRS(i)
'Response.Write(iRowCounter & "
")
'Response.Write(oRS(i) & "
")
Next
iRowCounter = iRowCounter + 1
oRS.MoveNext
Loop
Else
Response.Write("S")
End If
Else
aTemp = false
End If
oRS.Close
Set oRS = Nothing
ExecutePageQuery = aTemp
End Function
Function TExecutePgQuery(oConn,sQuery,iSize)
If Request.QueryString("pg") = "" Then
intCurrentPage = 1
Else
intCurrentPage = cInt(trim(Request.QueryString("pg")))
End If
Dim aRS()
Set oRS = Server.CreateObject("Adodb.RecordSet")
oRS.Open sQuery, oConn,3,3,1
oRS.PageSize = iSize
oRS.AbsolutePage = intCurrentPage
Response.Write(oRS.RecordCount & "
")
intCounter = 0
If Not oRS.EOF Then
ReDim aRS(oRS.Fields.Count - 1,oRS.RecordCount - 1)
Do While intCounter < intSize
'Response.Write(oRS.RecordCount)
intCol = 0
For Each oField In oRS.Fields
aRS(intCol,intCounter) = oField
Response.Write("" & intCol & " - " & intCounter & " = " & oField & "
")
intCol = intCol + 1
Next
intCounter = intCounter + 1
Response.Write("
")
oRS.MoveNext
Loop
Else
Response.Write("No Records Found")
End If
oRS.Close
Set oRS = Nothing
TExecutePgQuery = aRS
End Function
Function ExecutePgQuery(oConn,sQuery,iSize)
If Request.QueryString("showq") = 1 Then
Response.Write("
" & sQuery & "
")
End If
intCurrent = 1
If Request.QueryString("pg") <> "" Then
intCurrent = cInt(trim(Request.QueryString("pg")))
End If
Set oRS = Server.CreateObject("Adodb.RecordSet")
oRS.PageSize = cInt(iSize)
oRS.Open sQuery, oConn, 3,3,1
'Response.Write(oRS.RecordCount & "
")
intCounter = 0
If Not oRS.EOF Then
If intCurrent <= Ceil(oRS.RecordCount / iSize) Then
oRS.AbsolutePage = intCurrent
Dim aRS()
Redim aRS(oRS.Fields.Count,iSize)
'Do Until
For i = 0 to oRS.PageSize - 1
If Not oRS.EOF Then
'Do While oRS.EOF OR oRS.AbsolutePage <> intCurrent
intCol = 0
For Each sColVal in oRS.Fields
aRS(intCol,intCounter) = sColVal
'Response.Write(intCol & " - " & intCounter & " : " & sColVal & "
")
intCol = intCol + 1
Next
intCounter = intCounter + 1
oRS.MoveNext
'Loop
End If
Next
Redim Preserve aRS(intCol,intCounter - 1)
End If
End If
oRS.Close
Set oRS = Nothing
'For i = 0 to uBound(aRS,2)
'Response.Write(i & " - " & aRS(3,i) & "
")
'Next
ExecutePgQuery = aRS
End Function
Function ExecuteUpdate(oConn,sTable,aData)
sQ = "SELECT * FROM " & sTable & " WHERE id = " & aData("id")
Set oRS = Server.CreateObject("Adodb.RecordSet")
oRS.Open sQ, oConn,3,3,1
For Each Item in aData
Select Case Item
Case "id"
Case "submit"
Case Else
oRS(Item) = aData(Item)
End Select
Next
oRS.Update
oRS.Close
Set oRS = Nothing
ExecuteUpdate = True
End Function
Private Sub Class_Terminate()
End Sub
End Class
%>