错误:vb.netsqlite使用密码创建数据库

hk8txs48  于 2023-01-13  发布在  SQLite
关注(0)|答案(1)|浏览(202)

我面临的问题,当我尝试创建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文件复制到启动应用程序文件夹。我尝试卸载所有包并重新安装。我尝试创建新项目并执行所有提到的步骤。

ktecyv1j

ktecyv1j1#

安装此包SQLitePCLRaw.bundle_e_sqlcipher并在连接字符串中使用密码,如下所示:
数据源=”& DB_Path &“;密码= ashraf 123

相关问题