Skip to content

Commit 001cc25

Browse files
govert_cpgovert_cp
authored andcommitted
SQLiteForExcel Version 0.6 with SQLite3.dll version 3.7.5.
1 parent 1d84d53 commit 001cc25

12 files changed

Lines changed: 132 additions & 684 deletions

File tree

BuildProcessTemplates/DefaultTemplate.xaml

Lines changed: 0 additions & 602 deletions
This file was deleted.

BuildProcessTemplates/UpgradeTemplate.xaml

Lines changed: 0 additions & 76 deletions
This file was deleted.

Distribution/ChangeLog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Version 0.6 (8 April 2010)
2+
==========================
3+
* Fixed empty string bug.
4+
* Added SQLiteForWord example.
5+
* Updated Distribution version of SQLite3.dll to 3.7.5.
6+
17
Version 0.5 (6 August 2010)
28
===========================
39
* Fixed Excel 2003 compatibility - Byte() return becomes Variant.

Distribution/SQLite3_StdCall.dll

0 Bytes
Binary file not shown.

Distribution/SQLiteForExcel.xls

5.5 KB
Binary file not shown.

Distribution/SQLiteForWord.doc

133 KB
Binary file not shown.

Distribution/sqlite3.dll

38.1 KB
Binary file not shown.

Source/SQLite3VBAModules/Sqlite3.bas

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
Attribute VB_Name = "Sqlite3"
21
Option Explicit
32

43
' Notes:
@@ -360,15 +359,17 @@ Function Utf8PtrToString(ByVal pUtf8String As Long) As String
360359
Dim RetVal As Long
361360

362361
cSize = MultiByteToWideChar(CP_UTF8, 0, pUtf8String, -1, 0, 0)
363-
If cSize = 0 Then
362+
' cSize includes the terminating null character
363+
If cSize <= 1 Then
364+
Utf8PtrToString = ""
364365
Exit Function
365366
End If
366367

367368
Utf8PtrToString = String(cSize - 1, "*")
368369
RetVal = MultiByteToWideChar(CP_UTF8, 0, pUtf8String, cSize - 1, StrPtr(Utf8PtrToString), cSize - 1)
369370
If RetVal = 0 Then
370371
Debug.Print "Utf8PtrToString Error:", Err.LastDllError
371-
Return
372+
Exit Function
372373
End If
373374
End Function
374375

@@ -386,7 +387,7 @@ Function StringToUtf8Bytes(ByVal str As String) As Variant
386387
RetVal = WideCharToMultiByte(CP_UTF8, 0, StrPtr(str), -1, VarPtr(buf(0)), bSize, 0, 0)
387388
If RetVal = 0 Then
388389
Debug.Print "StringToUtf8Bytes Error:", Err.LastDllError
389-
Return
390+
Exit Function
390391
End If
391392
StringToUtf8Bytes = buf
392393
End Function

Source/SQLite3VBAModules/Sqlite3Demo.bas

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Public Sub AllTests()
1616
TestInsert
1717
TestSelect
1818
TestBinding
19-
'TestDates
19+
TestDates
20+
TestStrings
2021
TestBackup
21-
2222
SQLite3Free ' Quite optional
2323
End Sub
2424

@@ -838,6 +838,116 @@ Public Sub TestDates()
838838
Debug.Print "----- TestDates End -----"
839839
End Sub
840840

841+
842+
Public Sub TestStrings()
843+
Dim testFile As String
844+
845+
Dim myDbHandle As Long
846+
Dim myStmtHandle As Long
847+
Dim RetVal As Long
848+
Dim stepMsg As String
849+
Dim i As Long
850+
851+
Dim myString1 As String
852+
Dim myString2 As String
853+
Dim myStringResult As String
854+
855+
Debug.Print "----- TestStrings Start -----"
856+
857+
' Open the database - getting a DbHandle back
858+
testFile = "C:\TestSqlite3ForExcel.db3"
859+
RetVal = SQLite3Open(testFile, myDbHandle)
860+
Debug.Print "SQLite3Open returned " & RetVal
861+
862+
myString2 = ""
863+
864+
'------------------------
865+
' Create the table
866+
' ================
867+
' (I've got no error checking here...)
868+
SQLite3ExecuteNonQuery myDbHandle, "CREATE TABLE MyStringTable (MyValue TEXT)"
869+
870+
'-------------------------
871+
' Prepare an insert statement with parameters
872+
' ===============
873+
' Create the sql statement - getting a StmtHandle back
874+
RetVal = SQLite3PrepareV2(myDbHandle, "INSERT INTO MyStringTable Values (@SomeString)", myStmtHandle)
875+
If RetVal <> SQLITE_OK Then
876+
Debug.Print "SQLite3PrepareV2 returned " & SQLite3ErrMsg(myDbHandle)
877+
Beep
878+
End If
879+
880+
RetVal = SQLite3BindText(myStmtHandle, 1, myString1)
881+
If RetVal <> SQLITE_OK Then
882+
Debug.Print "SQLite3Bind returned " & RetVal, SQLite3ErrMsg(myDbHandle)
883+
Beep
884+
End If
885+
886+
RetVal = SQLite3Step(myStmtHandle)
887+
If RetVal <> SQLITE_DONE Then
888+
Debug.Print "SQLite3Step returned " & RetVal, SQLite3ErrMsg(myDbHandle)
889+
Beep
890+
End If
891+
892+
RetVal = SQLite3Reset(myStmtHandle)
893+
If RetVal <> SQLITE_OK Then
894+
Debug.Print "SQLite3Reset returned " & RetVal, SQLite3ErrMsg(myDbHandle)
895+
Beep
896+
End If
897+
898+
RetVal = SQLite3BindText(myStmtHandle, 1, myString2)
899+
If RetVal <> SQLITE_OK Then
900+
Debug.Print "SQLite3Bind returned " & RetVal, SQLite3ErrMsg(myDbHandle)
901+
Beep
902+
End If
903+
904+
RetVal = SQLite3Step(myStmtHandle)
905+
If RetVal <> SQLITE_DONE Then
906+
Debug.Print "SQLite3Step returned " & RetVal, SQLite3ErrMsg(myDbHandle)
907+
Beep
908+
End If
909+
910+
' Finalize the statement
911+
RetVal = SQLite3Finalize(myStmtHandle)
912+
Debug.Print "SQLite3Finalize returned " & RetVal
913+
914+
'-------------------------
915+
' Select statement
916+
' ===============
917+
' Create the sql statement - getting a StmtHandle back
918+
' Now using named parameters!
919+
RetVal = SQLite3PrepareV2(myDbHandle, "SELECT * FROM MyStringTable", myStmtHandle)
920+
Debug.Print "SQLite3PrepareV2 returned " & RetVal
921+
922+
RetVal = SQLite3Step(myStmtHandle)
923+
If RetVal = SQLITE_ROW Then
924+
' We have access to the result columns here.
925+
myStringResult = SQLite3ColumnText(myStmtHandle, 0)
926+
Debug.Print "Result1: " + myStringResult
927+
ElseIf RetVal = SQLITE_DONE Then
928+
Debug.Print "No row found"
929+
End If
930+
931+
RetVal = SQLite3Step(myStmtHandle)
932+
If RetVal = SQLITE_ROW Then
933+
' We have access to the result columns here.
934+
myStringResult = SQLite3ColumnText(myStmtHandle, 0)
935+
Debug.Print "Result2: " + myStringResult
936+
ElseIf RetVal = SQLITE_DONE Then
937+
Debug.Print "No row found"
938+
End If
939+
940+
' Finalize (delete) the statement
941+
RetVal = SQLite3Finalize(myStmtHandle)
942+
Debug.Print "SQLite3Finalize returned " & RetVal
943+
944+
' Close the database
945+
RetVal = SQLite3Close(myDbHandle)
946+
Kill testFile
947+
948+
Debug.Print "----- TestStrings End -----"
949+
End Sub
950+
841951
Public Sub TestBackup()
842952
Dim testFile As String
843953
Dim testFileBackup As String

Source/SQLite3_StdCall/sqlite3.def

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ sqlite3_blob_bytes
2323
sqlite3_blob_close
2424
sqlite3_blob_open
2525
sqlite3_blob_read
26+
sqlite3_blob_reopen
2627
sqlite3_blob_write
2728
sqlite3_busy_handler
2829
sqlite3_busy_timeout
@@ -64,6 +65,7 @@ sqlite3_create_collation16
6465
sqlite3_create_collation_v2
6566
sqlite3_create_function
6667
sqlite3_create_function16
68+
sqlite3_create_function_v2
6769
sqlite3_create_module
6870
sqlite3_create_module_v2
6971
sqlite3_data_count
@@ -142,16 +144,19 @@ sqlite3_result_text16le
142144
sqlite3_result_value
143145
sqlite3_result_zeroblob
144146
sqlite3_rollback_hook
147+
sqlite3_rtree_geometry_callback
145148
sqlite3_set_authorizer
146149
sqlite3_set_auxdata
147150
sqlite3_shutdown
148151
sqlite3_sleep
149152
sqlite3_snprintf
150153
sqlite3_soft_heap_limit
154+
sqlite3_soft_heap_limit64
151155
sqlite3_sourceid
152156
sqlite3_sql
153157
sqlite3_status
154158
sqlite3_step
159+
sqlite3_stmt_readonly
155160
sqlite3_stmt_status
156161
sqlite3_strnicmp
157162
sqlite3_table_column_metadata
@@ -180,4 +185,8 @@ sqlite3_vfs_find
180185
sqlite3_vfs_register
181186
sqlite3_vfs_unregister
182187
sqlite3_vmprintf
188+
sqlite3_vsnprintf
189+
sqlite3_wal_autocheckpoint
190+
sqlite3_wal_checkpoint
191+
sqlite3_wal_hook
183192
sqlite3_win32_mbcs_to_utf8

0 commit comments

Comments
 (0)