'打开SQLite数据库
'返回=0 成功  非零，打开失败
'用 SQLiteErrMsg(返回值)获取错误字符
'例题：
'   Dim as sqlite3 Ptr hDB 
'   Print SQLiteOpen (hDB,"sqlite3_test.db","ddd")
Function SQLiteOpen(ByRef db As SQLite3 Ptr, ByVal sFileSpec As String, ByVal Password As String = "") As Integer
   '打开数据库，可以有密码
   
   Dim szFileSpec As ZString * 500
   Dim r As Long
   szFileSpec = StrToUtf8(sFileSpec) & Chr(0)
   r = sqlite3_open(@szFileSpec, @DB)
   
   If r Then '出错
      'ErrStr = *sqlite3_errmsg(DB)
      sqlite3_close(DB)
      Return r
   End If
   'FilePath = sFileSpec
   If Len(Password) Then '有密码
      'If sqlite3_key(DB,ByVal StrPtr(Password),Len(Password)) Then
      ''             Print "失败" 'SQLiteErrMsg(hDB)
      'End If
      'If sqlite3_key(hDB,ByVal StrPtr(Password),Len(Password)) Then
      '?  SQLiteErrMsg(hDB)
      'End If
   End If
   
End Function