VB使用Sqlite 3
国内は今VBを使うのが少なくなったようで、1つのプロジェクトはSqlite 3を使って、関連資料が比較的に乱れていることを発見して、多くの異なる使用方法があります.注意しなければならないのは、Vb呼び出しSqlite 3は添付ファイルのdllを使用することができ、公式サイトのダウンロードは使いにくい(登録はいつも失敗している).特に使用方法をここに記録します.
1.添付ファイルのクラスモジュールcCDECLを追加する.cls
2.添付のモジュールを追加する.bas,mSqlite.bas
3.
data
---data.sqlite
vb
---
自分で使用するときは、データベースパスの変更に注意してください.
--添付ファイルをアップロードする場所が見つからず、ダウンロードリソースに入れました.ここでは他人のプログラムを直接使って、原作者に感謝します.
ダウンロードページをクリック
1.添付ファイルのクラスモジュールcCDECLを追加する.cls
2.添付のモジュールを追加する.bas,mSqlite.bas
3.
Private Sub checkHistory()
Dim sPath As String
sPath = App.path & "\..\data\"
If mSqlite.sqlite3_initialize(sPath) <> SQLITE_OK Then
Debug.Print "error"
Exit Sub
End If
If mSqlite.sqlite3_open(sPath & "data.sqlite", f_lSqlite) <> SQLITE_OK Then
Debug.Print "error"
Exit Sub
End If
If mSqlite.sqlite3_prepare_v2(f_lSqlite, "SELECT id,flag,send_username,send_cop,send_mail,send_phone,cmbType,cmbW,cmbC,cmbH FROM history WHERE flag=0", 0, f_lStatement, 0) = SQLITE_OK Then
Dim send_username As String, send_cop As String, send_mail As String, send_phone As String
Dim cmbType As String, cmbW As Integer, cmbC As Integer, cmbH As Integer
' add lasttime
Do While mSqlite.sqlite3_step(f_lStatement) = SQLITE_ROW
Debug.Print mSqlite.sqlite3_column_int(f_lStatement, 0)
Debug.Print mSqlite.sqlite3_column_text(f_lStatement, 1)
send_username = mSqlite.sqlite3_column_text(f_lStatement, 2)
send_cop = mSqlite.sqlite3_column_text(f_lStatement, 3)
send_mail = mSqlite.sqlite3_column_text(f_lStatement, 4)
send_phone = mSqlite.sqlite3_column_text(f_lStatement, 5)
cmbType = mSqlite.sqlite3_column_text(f_lStatement, 6)
cmbW = mSqlite.sqlite3_column_int(f_lStatement, 7)
cmbC = mSqlite.sqlite3_column_int(f_lStatement, 8)
cmbH = mSqlite.sqlite3_column_int(f_lStatement, 9)
generate send_username, send_cop, send_mail, send_phone, cmbType, cmbW, cmbC, cmbH
mSqlite.sqlite3_exec f_lSqlite, "UPDATE history set flag=1 WHERE id=" & mSqlite.sqlite3_column_int(f_lStatement, 0)
Loop
Else
Debug.Print mSqlite.sqlite3_errmsg(f_lSqlite)
End If
Call mSqlite.sqlite3_finalize(f_lStatement)
'// Close DB handle
Call mSqlite.sqlite3_close(f_lSqlite)
'// Terminate wrapper
Call mSqlite.sqlite3_shutdown
End Sub
私のプロジェクトディレクトリ構造は次のとおりです.data
---data.sqlite
vb
---
自分で使用するときは、データベースパスの変更に注意してください.
--添付ファイルをアップロードする場所が見つからず、ダウンロードリソースに入れました.ここでは他人のプログラムを直接使って、原作者に感謝します.
ダウンロードページをクリック