code_junkie

Microsoft.ACE.OLEDB.12.0 provider is not registered

Nov 11th, 2011
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. private class AdminDatabase
  2. ' stores the connection string which is set in the New() method
  3. dim strAdminConnection as string
  4.  
  5. public sub New()
  6. ...
  7. adminName = dlgopen.FileName
  8. conAdminDB = New OleDbConnection
  9. conAdminDB.ConnectionString = "Data Source='" + adminName + "';" + _
  10. "Provider=Microsoft.ACE.OLEDB.12.0"
  11.  
  12. ' store the connection string in strAdminConnection
  13. strAdminConnection = conAdminDB.ConnectionString.ToString()
  14. My.Settings.SetUserOverride("AdminConnectionString", strAdminConnection)
  15. ...
  16. End Sub
  17.  
  18. ' retrieves data from the database
  19. Public Function getDataTable(ByVal sqlStatement As String) As DataTable
  20. Dim ds As New DataSet
  21. Dim dt As New DataTable
  22. Dim da As New OleDbDataAdapter
  23. Dim localCon As New OleDbConnection
  24.  
  25.  
  26. localCon.ConnectionString = strAdminConnection
  27.  
  28. Using localCon
  29. Dim command As OleDbCommand = localCon.CreateCommand()
  30. command.CommandText = sqlStatement
  31. localCon.Open()
  32. da.SelectCommand = command
  33. da.Fill(dt)
  34. getDataTable = dt
  35. End Using
  36.  
  37. End Function
  38. End Class
Add Comment
Please, Sign In to add comment