请我尝试将SQLite数据库中的所有表加载到组合框中我一直收到错误:System.Data.SQLite.dll中出现未处理的类型'System.ArgumentException'异常
附加信息:部件“C:\ SQliteTest \ sqlite_test \ bin \ Debug \ test.db”的ConnectionString格式无效,未找到等号:
以下是我的代码。 VS一直强调: SQLconnect.Open()
Dim db As String =“C:\ SQliteTest \ sqlite_test \ bin \ Debug \ test.db; Version = 3;”
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim SQLconnect As New SQLite.SQLiteConnection()
Dim SQLcommand As SQLiteCommand
SQLconnect.ConnectionString = db
SQLconnect.Open()
SQLcommand = SQLconnect.CreateCommand
Dim SchemaTable = SQLconnect.GetSchema(SQLiteMetaDataCollectionNames.Tables)
For int As Integer = 0 To SchemaTable.Rows.Count - 1
If SchemaTable.Rows(int)!TABLE_TYPE.ToString = "table" Then
Me.ComboBox1.Items.Add(SchemaTable.Rows(int)!TABLE_NAME.ToString())
End If
Next
SQLcommand.Dispose()
SQLconnect.Close()
End Sub
答案 0 :(得分:0)
假设您使用的是SQLite.NET提供程序,那么连接应该如下所示:
Dim db As String = "Data Source=C:\SQliteTest\sqlite_test\bin\Debug\test.db; Version=3;"
有关详细信息和示例,请参阅The Connection Strings Reference。