试图将一些历史记录写入访问数据库,但我不断收到一条错误消息,指出the path is invalid
. 我正在使用连接字符串,并且从向导本身获取它。复制和粘贴。谁能帮我吗?
谢谢
Imports System.IO
Imports System.Data.OleDb
Public Class theControls
'The History Database Connection String
Dim theHistoryDatabaseConn As New OleDbConnection
Private Sub ComboBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles theAddressBar.KeyDown
'Navigate to Webpage stated in theAddressBar
If e.KeyValue = Keys.Enter Then
theBrowser.Navigate(theAddressBar.Text)
e.SuppressKeyPress = True
End If
End Sub
Private Sub goForward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles goForward.Click
theBrowser.GoForward()
End Sub
Private Sub goBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles goBack.Click
theBrowser.GoBack()
End Sub
Private Sub theBrowser_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles theBrowser.DocumentCompleted
'Set Tab Text to current web page
Form1.TabControl1.SelectedTab.Text = theBrowser.Url.Host.ToString
'The History
theHistoryDatabaseConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\bin\Debug\TheHistoryDB.accdb"
Dim theCommand As OleDbCommand = New OleDbCommand("INSERT INTO TheHistory ([Site]) VALUES (theBrowser.URL.Host)", theHistoryDatabaseConn)
theCommand.Parameters.Add("@Site", OleDbType.Char, 255).Value = theBrowser.Url.Host.ToString
Try
theHistoryDatabaseConn.Open()
theCommand.ExecuteNonQuery()
Catch ex As Exception
Throw ex
Finally
theHistoryDatabaseConn.Close()
End Try
theHistoryDatabaseConn.Close()
End Sub
Private Sub theBrowser_ProgressChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles theBrowser.ProgressChanged
'Status Bar Text
Label1.Text = theBrowser.StatusText.ToString
End Sub
End Class