VB SQLite 유용한 함수
페이지 정보
작성자
본문
Private Declare Sub sqlite3_open Lib "SQLite3VB.dll" (ByVal FileName As String, ByRef handle As Long)
Private Declare Sub sqlite3_close Lib "SQLite3VB.dll" (ByVal DB_Handle As Long)
Private Declare Function sqlite3_last_insert_rowid Lib "SQLite3VB.dll" (ByVal DB_Handle As Long) As Long
Private Declare Function sqlite3_changes Lib "SQLite3VB.dll" (ByVal DB_Handle As Long) As Long
Private Declare Function sqlite_get_table Lib "SQLite3VB.dll" (ByVal DB_Handle As Long, _
ByVal SQLString As String, ByRef ErrStr As String) As Variant()
Private Declare Function sqlite_libversion Lib "SQLite3VB.dll" () As String ' Now returns a BSTR
Private Declare Function number_of_rows_from_last_call Lib "SQLite3VB.dll" () As Long
Private Function DBQuery(ByVal DBFile As String, ByVal QueryStr As String, ByRef ErrStr As String) As Long
On Error GoTo ERR_TRAP
Dim DB As Long
Dim i As Long
Dim mVar As Variant ' Will hold our results
Dim mV1 As Variant ' Will be used to get each individual result
Dim mErrStr As String
Dim mStr As String
Dim mRowCnt As Long
Dim mCurColumn As String
Dim LI As ListItem
If QueryStr = "" Or DBFile = "" Then Exit Function
sqlite3_open DBFile, DB
If DB > 0 Then
mVar = sqlite_get_table(DB, QueryStr, mErrStr)
If mErrStr <> "" Then
ErrStr = mErrStr
sqlite3_close DB
Exit Function
Else
mRowCnt = number_of_rows_from_last_call
If mRowCnt > 0 Then
For Each mV1 In mVar
mStr = mV1
If i = 0 Then
mCurColumn = mStr
lvResults.ColumnHeaders.Add , mCurColumn, mCurColumn
Else
If lvResults.ColumnHeaders.Count = 1 Then
lvResults.ListItems.Add , , mStr
ElseIf lvResults.ColumnHeaders.Count > 1 Then
Set LI = lvResults.ListItems(i)
LI.SubItems(lvResults.ColumnHeaders.Count - 1) = mStr
End If
End If
i = i + 1
If i > mRowCnt Then
i = 0
End If
Next
End If
End If
sqlite3_close DB
End If
DBQuery = lvResults.ListItems.Count
Exit Function
ERR_TRAP:
ErrStr = Err.Description
End Function
Private Declare Sub sqlite3_close Lib "SQLite3VB.dll" (ByVal DB_Handle As Long)
Private Declare Function sqlite3_last_insert_rowid Lib "SQLite3VB.dll" (ByVal DB_Handle As Long) As Long
Private Declare Function sqlite3_changes Lib "SQLite3VB.dll" (ByVal DB_Handle As Long) As Long
Private Declare Function sqlite_get_table Lib "SQLite3VB.dll" (ByVal DB_Handle As Long, _
ByVal SQLString As String, ByRef ErrStr As String) As Variant()
Private Declare Function sqlite_libversion Lib "SQLite3VB.dll" () As String ' Now returns a BSTR
Private Declare Function number_of_rows_from_last_call Lib "SQLite3VB.dll" () As Long
Private Function DBQuery(ByVal DBFile As String, ByVal QueryStr As String, ByRef ErrStr As String) As Long
On Error GoTo ERR_TRAP
Dim DB As Long
Dim i As Long
Dim mVar As Variant ' Will hold our results
Dim mV1 As Variant ' Will be used to get each individual result
Dim mErrStr As String
Dim mStr As String
Dim mRowCnt As Long
Dim mCurColumn As String
Dim LI As ListItem
If QueryStr = "" Or DBFile = "" Then Exit Function
sqlite3_open DBFile, DB
If DB > 0 Then
mVar = sqlite_get_table(DB, QueryStr, mErrStr)
If mErrStr <> "" Then
ErrStr = mErrStr
sqlite3_close DB
Exit Function
Else
mRowCnt = number_of_rows_from_last_call
If mRowCnt > 0 Then
For Each mV1 In mVar
mStr = mV1
If i = 0 Then
mCurColumn = mStr
lvResults.ColumnHeaders.Add , mCurColumn, mCurColumn
Else
If lvResults.ColumnHeaders.Count = 1 Then
lvResults.ListItems.Add , , mStr
ElseIf lvResults.ColumnHeaders.Count > 1 Then
Set LI = lvResults.ListItems(i)
LI.SubItems(lvResults.ColumnHeaders.Count - 1) = mStr
End If
End If
i = i + 1
If i > mRowCnt Then
i = 0
End If
Next
End If
End If
sqlite3_close DB
End If
DBQuery = lvResults.ListItems.Count
Exit Function
ERR_TRAP:
ErrStr = Err.Description
End Function
첨부파일
- SQLite3VB.dll (340.0K) 32회 다운로드 | DATE : 2013-12-16 00:30:39
댓글목록
등록된 댓글이 없습니다.