簡體   English   中英

錯誤:vb.net sqlite create database with password

[英]Error : vb.net sqlite create database with password

當我嘗試使用密碼創建 sqlite 數據庫時遇到問題。

當我創建沒有密碼的數據庫時它工作得很好但是如果我嘗試設置密碼它給我錯誤消息“無法加載文件或程序集'System.Data.SQLite.SEE.License,Version = 1.0.117.0,Culture = neutral , PublicKeyToken=433d9874d0bb98c5' 或其依賴項之一。系統找不到指定的文件。”。

錯誤信息

我的代碼: 我的代碼

我安裝的包

我的代碼是:

Imports System.Data.SQLite
Imports System.IO

Public Class Form1
    Dim DB_Path As String = Application.StartupPath & "\DB\database.sqlite"

    Private Async Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Try
            If File.Exists(DB_Path) = False Then
                ' create db folder if not exist
                If Not (System.IO.Directory.Exists(Application.StartupPath & "\DB\")) Then
                    System.IO.Directory.CreateDirectory(Application.StartupPath & "\DB\")
                End If

                ' Create a new SQLite connection
                Using conn As New SQLiteConnection("Data Source=" & Application.StartupPath & "\DB\database.sqlite" & ";Version=3;")

                    'set db password
                    conn.SetPassword("ashraf123") ' the error here
                    'change db conn string
                    conn.ConnectionString = "Data Source=" & DB_Path & ";Password=ashraf123;Version=3;"
                    'open conn
                    Await conn.OpenAsync
                    ' do somthing

                End Using
            Else

                Using conn As New SQLiteConnection("Data Source=" & DB_Path & ";Password=ashraf123;Version=3;")
                    Await conn.OpenAsync
                    ' do somthing

                End Using
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

    End Sub

End Class

我嘗試將平台從任何 cpu 更改為 x86。我嘗試將平台從任何 cpu 更改為 x64。 我嘗試將 system.data.sqlite.dll 和所有其他 .dll 文件復制到啟動應用程序文件夾。 我嘗試卸載所有軟件包並重新安裝它們。 我嘗試創建新項目並執行所有提到的步驟。

安裝此 package SQLitePCLRaw.bundle_e_sqlcipher並在連接字符串中使用密碼,如下所示:

Data Source=" & DB_Path & ";密碼=ashraf123

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM