I'm trying to write data to an Access 2010 table from VB 2010. Here's the VB code:
Dim cn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\ssr2011f\be\ssrAnalysisTWEAK.ACCdb")
cn.Open()
Dim Str As String = "insert into BSP1 values(" & CInt(pcValue) & ",'" & (hsName) & ") "
Dim cmd As New System.Data.OleDb.OleDbCommand(Str, cn)
Dim icount As Integer = cmd.ExecuteNonQuery
I get the following error at the line "cn.Open()":
A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll
I also got this error using the Connection string "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ssr2011f\be\ssrAnalysisTWEAK.ACCdb;". My Windows version is 7.0.
Why is the connection failing?