Results 1 to 17 of 17

Thread: ADO.NET Can't Open Database File

  1. #1

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    ADO.NET Can't Open Database File

    Hey guys, long time no see. I decided to play around with SQL using VB.Net with ADO.Net, and for some reason I just can't seem to connect to the database file. I used Tools > Connect to Database, and linked the file with that, which is an accdb file from Access. Didn't change anything really afterwards. And then I ran this code:

    vb.net Code:
    1. Option Explicit On
    2. Option Strict On
    3. Imports System.Data.SqlClient
    4.  
    5. Public Class Form1
    6.     Private myConn As SqlConnection
    7.     Private myCmd As SqlCommand
    8.     Private myReader As SqlDataReader
    9.     Private results As String
    10.  
    11.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    12.         myConn = New SqlConnection("Data Source = Database1")
    13.  
    14.         'Open the connection.
    15.         myConn.Open()
    16.     End Sub
    17.  
    18.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    19.         'Create a Command object.
    20.         myCmd = myConn.CreateCommand
    21.         myCmd.CommandText = "SELECT * FROM Table1 WHERE ID = " & TextBox1.Text
    22.         myReader = myCmd.ExecuteReader()
    23.         results = results & myReader.GetString(0) & vbTab & myReader.GetString(1)
    24.         Label1.Text = results
    25.     End Sub
    26. End Class

    As a result, I get an unhandled exception. I even tried using an mdb file, and it still fails. Even tried adding "Initial Catalog=Database1;Integrated Security=True" for the myConn connection, and nothing worked. Anyone got any bright ideas? Thanks in advance.

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: ADO.NET Can't Open Database File

    Access database files use OLEDB. Your trying to use SqlClient. Also, you should always provide what error your getting.

  3. #3

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    Re: ADO.NET Can't Open Database File

    This is the error I received with the original way
    Attached Images Attached Images  

  4. #4

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    Re: ADO.NET Can't Open Database File

    So I tried with this new code here:

    vb.net Code:
    1. Option Explicit On
    2. Option Strict On
    3. Imports System.Data.OleDb
    4.  
    5. Public Class Form1
    6.     Private myConn As OleDbConnection
    7.     Private oledbAdapter As OleDbDataAdapter
    8.     Dim ds As New DataSet
    9.     Private results As String
    10.  
    11.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    12.         myConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.12.0;Data Source = Database1")
    13.  
    14.         myConn.Open()
    15.     End Sub
    16.  
    17.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    18.         oledbAdapter = New OleDbDataAdapter("SELECT * FROM Table1 WHERE ID = " & TextBox1.Text, myConn)
    19.         oledbAdapter.Fill(ds)
    20.         oledbAdapter.Dispose()
    21.         results = ds.Tables(0).Rows(0).Item(0).ToString + Environment.NewLine + ", " + ds.Tables(0).Rows(0).Item(1).ToString
    22.         Label1.Text = results
    23.     End Sub
    24. End Class

    And now it is saying "The 'Microsoft.Jet.OLEDB.12.0' provider is not registered on the local machine." I tried reinstalling the 2010 version, the 2007 version, and even the 2016 version, and I still get the same error. And yes my project is set to x86. My Office products are also 32 bit.

  5. #5
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,393

    Re: ADO.NET Can't Open Database File

    The actual Details of the error message is what we would want to see to help determine the issue. If you copy the text from the box below the Details, Continue, and Quit buttons and paste it (or at least the topmost section) into a Code box here, that might be useful.

  6. #6

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    Re: ADO.NET Can't Open Database File

    Ok here ya go:

    Code:
    Unhandled exception has occured in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.
    
    The 'Microsoft.Jet.OLEDB.12.0' provider is not registered on the local machine.
    
    Details:
    See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.
    
    ************** Exception Text **************
    System.InvalidOperationException: The 'Microsoft.Jet.OLEDB.12.0' provider is not registered on the local machine.
       at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper)
       at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
       at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.OleDb.OleDbConnection.Open()
       at SQL_Tutorial.Form1.Form1_Load(Object sender, EventArgs e) in D:\Source Code\VB.Net\SQL Tutorial\SQL Tutorial\Form1.vb:line 14
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
    
    
    ************** Loaded Assemblies **************
    System.Private.CoreLib
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Private.CoreLib.dll
    ----------------------------------------
    SQL Tutorial
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///D:/Source%20Code/VB.Net/SQL%20Tutorial/SQL%20Tutorial/bin/x86/Debug/net5.0-windows/SQL%20Tutorial.dll
    ----------------------------------------
    Microsoft.VisualBasic.Forms
        Assembly Version: 5.0.7.0
        Win32 Version: 5.0.721.26307
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/Microsoft.VisualBasic.Forms.dll
    ----------------------------------------
    System.Runtime
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Runtime.dll
    ----------------------------------------
    System.Windows.Forms.Primitives
        Assembly Version: 5.0.7.0
        Win32 Version: 5.0.721.26307
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/System.Windows.Forms.Primitives.dll
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 5.0.7.0
        Win32 Version: 5.0.721.26307
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/System.Windows.Forms.dll
    ----------------------------------------
    System.Diagnostics.TraceSource
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Diagnostics.TraceSource.dll
    ----------------------------------------
    System.Collections
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Collections.dll
    ----------------------------------------
    System.ComponentModel.Primitives
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.ComponentModel.Primitives.dll
    ----------------------------------------
    System.Runtime.InteropServices
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Runtime.InteropServices.dll
    ----------------------------------------
    System.Drawing.Primitives
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Drawing.Primitives.dll
    ----------------------------------------
    System.Collections.Specialized
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Collections.Specialized.dll
    ----------------------------------------
    System.Security.Permissions
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.20.51904
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/System.Security.Permissions.dll
    ----------------------------------------
    System.Threading
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Threading.dll
    ----------------------------------------
    System.Security.Principal.Windows
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Security.Principal.Windows.dll
    ----------------------------------------
    System.Security.Claims
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Security.Claims.dll
    ----------------------------------------
    Microsoft.Win32.Primitives
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/Microsoft.Win32.Primitives.dll
    ----------------------------------------
    System.Threading.Thread
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Threading.Thread.dll
    ----------------------------------------
    System.ComponentModel.EventBasedAsync
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.ComponentModel.EventBasedAsync.dll
    ----------------------------------------
    System.Drawing.Common
        Assembly Version: 5.0.0.2
        Win32 Version: 5.0.421.11614
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/System.Drawing.Common.dll
    ----------------------------------------
    Accessibility
        Assembly Version: 4.0.0.0
        Win32 Version: 5.0.721.26307
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/Accessibility.dll
    ----------------------------------------
    System.ComponentModel
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.ComponentModel.dll
    ----------------------------------------
    System.ComponentModel.TypeConverter
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.ComponentModel.TypeConverter.dll
    ----------------------------------------
    Microsoft.VisualBasic.Core
        Assembly Version: 10.0.6.0
        Win32 Version: 11.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/Microsoft.VisualBasic.Core.dll
    ----------------------------------------
    System.Data.Common
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Data.Common.dll
    ----------------------------------------
    System.Xml.ReaderWriter
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Xml.ReaderWriter.dll
    ----------------------------------------
    System.Private.Xml
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Private.Xml.dll
    ----------------------------------------
    System.Runtime.Extensions
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Runtime.Extensions.dll
    ----------------------------------------
    System.Memory
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Memory.dll
    ----------------------------------------
    Microsoft.Win32.SystemEvents
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.20.51904
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/Microsoft.Win32.SystemEvents.dll
    ----------------------------------------
    System.Buffers
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Buffers.dll
    ----------------------------------------
    System.Collections.NonGeneric
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Collections.NonGeneric.dll
    ----------------------------------------
    System.Data.OleDb
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.20.51904
        CodeBase: file:///D:/Source%20Code/VB.Net/SQL%20Tutorial/SQL%20Tutorial/bin/x86/Debug/net5.0-windows/runtimes/win/lib/netstandard2.0/System.Data.OleDb.dll
    ----------------------------------------
    netstandard
        Assembly Version: 2.1.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/netstandard.dll
    ----------------------------------------
    System.Transactions.Local
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Transactions.Local.dll
    ----------------------------------------
    System.Diagnostics.PerformanceCounter
        Assembly Version: 5.0.0.1
        Win32 Version: 5.0.321.7212
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/System.Diagnostics.PerformanceCounter.dll
    ----------------------------------------
    System.Collections.Concurrent
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Collections.Concurrent.dll
    ----------------------------------------
    Microsoft.Win32.Registry
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/Microsoft.Win32.Registry.dll
    ----------------------------------------
    System.Diagnostics.Tracing
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Diagnostics.Tracing.dll
    ----------------------------------------
    System.Diagnostics.FileVersionInfo
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Diagnostics.FileVersionInfo.dll
    ----------------------------------------
    System.Runtime.InteropServices.RuntimeInformation
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Runtime.InteropServices.RuntimeInformation.dll
    ----------------------------------------
    System.Private.Uri
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Private.Uri.dll
    ----------------------------------------
    System.Diagnostics.StackTrace
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Diagnostics.StackTrace.dll
    ----------------------------------------
    System.Reflection.Metadata
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Reflection.Metadata.dll
    ----------------------------------------
    System.IO.FileSystem
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.IO.FileSystem.dll
    ----------------------------------------
    System.Collections.Immutable
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Collections.Immutable.dll
    ----------------------------------------
    System.Text.Encoding.Extensions
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Text.Encoding.Extensions.dll
    ----------------------------------------
    
    ************** JIT Debugging **************

  7. #7
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,393

    Re: ADO.NET Can't Open Database File

    Possibly useful links for the error message in Post #6:

    https://www.mikesdotnetting.com/arti...the-local-mach

    https://stackoverflow.com/questions/...-local-machine

    https://docs.microsoft.com/en-us/ans...is-not-re.html

    For the only partially visible error details in the message from Post #3, we would need the Details for that one also.

  8. #8
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: ADO.NET Can't Open Database File

    Quote Originally Posted by Jacob Roman
    which is an accdb file from Access.
    ACCDB is different from mdb, which used the Jet drivers... Try using the ACE ones instead.

    https://www.connectionstrings.com/ace-oledb-12-0/



    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    Re: ADO.NET Can't Open Database File

    Quote Originally Posted by jdc2000 View Post
    Possibly useful links for the error message in Post #6:

    https://www.mikesdotnetting.com/arti...the-local-mach

    https://stackoverflow.com/questions/...-local-machine

    https://docs.microsoft.com/en-us/ans...is-not-re.html

    For the only partially visible error details in the message from Post #3, we would need the Details for that one also.
    Ok no problem. This was the error from the original code when I was attempting to use ADO.NET:

    Code:
    Unhandled exception has occured in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.
    
    The 'Microsoft.Jet.OLEDB.12.0' provider is not registered on the local machine.
    
    A network-related or instance-specidic error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server).
    
    Details:
    See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.
    
    ************** Exception Text **************
    System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
     ---> System.ComponentModel.Win32Exception (53): The network path was not found.
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
       at System.Data.SqlClient.SqlConnection.Open()
       at SQL_Tutorial.Form1.Form1_Load(Object sender, EventArgs e) in D:\Source Code\VB.Net\SQL Tutorial\SQL Tutorial\Form1.vb:line 15
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
    ClientConnectionId:00000000-0000-0000-0000-000000000000
    Error Number:53,State:0,Class:20
    
    
    ************** Loaded Assemblies **************
    System.Private.CoreLib
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Private.CoreLib.dll
    ----------------------------------------
    SQL Tutorial
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///D:/Source%20Code/VB.Net/SQL%20Tutorial/SQL%20Tutorial/bin/x86/Debug/net5.0-windows/SQL%20Tutorial.dll
    ----------------------------------------
    Microsoft.VisualBasic.Forms
        Assembly Version: 5.0.7.0
        Win32 Version: 5.0.721.26307
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/Microsoft.VisualBasic.Forms.dll
    ----------------------------------------
    System.Runtime
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Runtime.dll
    ----------------------------------------
    System.Windows.Forms.Primitives
        Assembly Version: 5.0.7.0
        Win32 Version: 5.0.721.26307
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/System.Windows.Forms.Primitives.dll
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 5.0.7.0
        Win32 Version: 5.0.721.26307
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/System.Windows.Forms.dll
    ----------------------------------------
    System.Diagnostics.TraceSource
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Diagnostics.TraceSource.dll
    ----------------------------------------
    System.Collections
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Collections.dll
    ----------------------------------------
    System.ComponentModel.Primitives
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.ComponentModel.Primitives.dll
    ----------------------------------------
    System.Runtime.InteropServices
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Runtime.InteropServices.dll
    ----------------------------------------
    System.Drawing.Primitives
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Drawing.Primitives.dll
    ----------------------------------------
    System.Collections.Specialized
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Collections.Specialized.dll
    ----------------------------------------
    System.Security.Permissions
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.20.51904
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/System.Security.Permissions.dll
    ----------------------------------------
    System.Threading
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Threading.dll
    ----------------------------------------
    System.Security.Principal.Windows
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Security.Principal.Windows.dll
    ----------------------------------------
    System.Security.Claims
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Security.Claims.dll
    ----------------------------------------
    Microsoft.Win32.Primitives
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/Microsoft.Win32.Primitives.dll
    ----------------------------------------
    System.Threading.Thread
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Threading.Thread.dll
    ----------------------------------------
    System.ComponentModel.EventBasedAsync
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.ComponentModel.EventBasedAsync.dll
    ----------------------------------------
    System.Drawing.Common
        Assembly Version: 5.0.0.2
        Win32 Version: 5.0.421.11614
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/System.Drawing.Common.dll
    ----------------------------------------
    Accessibility
        Assembly Version: 4.0.0.0
        Win32 Version: 5.0.721.26307
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/Accessibility.dll
    ----------------------------------------
    System.ComponentModel
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.ComponentModel.dll
    ----------------------------------------
    System.ComponentModel.TypeConverter
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.ComponentModel.TypeConverter.dll
    ----------------------------------------
    Microsoft.VisualBasic.Core
        Assembly Version: 10.0.6.0
        Win32 Version: 11.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/Microsoft.VisualBasic.Core.dll
    ----------------------------------------
    System.Runtime.Extensions
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Runtime.Extensions.dll
    ----------------------------------------
    System.Memory
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Memory.dll
    ----------------------------------------
    Microsoft.Win32.SystemEvents
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.20.51904
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.WindowsDesktop.App/5.0.7/Microsoft.Win32.SystemEvents.dll
    ----------------------------------------
    System.Buffers
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Buffers.dll
    ----------------------------------------
    System.Collections.NonGeneric
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Collections.NonGeneric.dll
    ----------------------------------------
    System.Data.SqlClient
        Assembly Version: 4.6.1.2
        Win32 Version: 4.700.20.37001
        CodeBase: file:///D:/Source%20Code/VB.Net/SQL%20Tutorial/SQL%20Tutorial/bin/x86/Debug/net5.0-windows/runtimes/win/lib/netcoreapp2.1/System.Data.SqlClient.dll
    ----------------------------------------
    System.Data.Common
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Data.Common.dll
    ----------------------------------------
    System.Transactions.Local
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Transactions.Local.dll
    ----------------------------------------
    System.Threading.Tasks
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Threading.Tasks.dll
    ----------------------------------------
    System.Diagnostics.DiagnosticSource
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Diagnostics.DiagnosticSource.dll
    ----------------------------------------
    System.Diagnostics.Tracing
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Diagnostics.Tracing.dll
    ----------------------------------------
    System.Threading.Timer
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Threading.Timer.dll
    ----------------------------------------
    System.Collections.Concurrent
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Collections.Concurrent.dll
    ----------------------------------------
    System.Threading.ThreadPool
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Threading.ThreadPool.dll
    ----------------------------------------
    System.Text.Encoding.CodePages
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Text.Encoding.CodePages.dll
    ----------------------------------------
    System.Resources.ResourceManager
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Resources.ResourceManager.dll
    ----------------------------------------
    System.Private.Uri
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Private.Uri.dll
    ----------------------------------------
    System.Diagnostics.StackTrace
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Diagnostics.StackTrace.dll
    ----------------------------------------
    System.Reflection.Metadata
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Reflection.Metadata.dll
    ----------------------------------------
    System.IO.FileSystem
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.IO.FileSystem.dll
    ----------------------------------------
    System.Collections.Immutable
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Collections.Immutable.dll
    ----------------------------------------
    System.Text.Encoding.Extensions
        Assembly Version: 5.0.0.0
        Win32 Version: 5.0.721.25508
        CodeBase: file:///C:/Program%20Files%20(x86)/dotnet/shared/Microsoft.NETCore.App/5.0.7/System.Text.Encoding.Extensions.dll
    ----------------------------------------
    
    ************** JIT Debugging **************

  10. #10
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: ADO.NET Can't Open Database File

    Also, if you want to use a MDB then you use the Jet provider and you should set the compiler to target x86 CPU

  11. #11

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    Re: ADO.NET Can't Open Database File

    Quote Originally Posted by wes4dbt View Post
    Also, if you want to use a MDB then you use the Jet provider and you should set the compiler to target x86 CPU
    I did that long ago. Already mentioned earlier

  12. #12
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: ADO.NET Can't Open Database File

    Interesting choice in provider, Microsoft.Jet.OLEDB.12.0, try Microsoft.Jet.OLEDB.4.0;

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: ADO.NET Can't Open Database File

    As suggested, there's no such thing as Jet 12. Jet 4 is the old provider that is effectively built into Windows and supports MDB, XLS and other old-format files. ACE 12 is the new provider that needs to be installed separately, possibly as part of Office, and also supports ACCDB, XLSX and other new-format files. Jet 4 is only available in 32-bit form, while ACE is available in both 32-bit and 64-bit.

  14. #14

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    Re: ADO.NET Can't Open Database File

    Crap, no wonder. Changed that code to this: myConn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source = Database1.accdb") and it worked! So theres no way ADO.NET can open such files ehy?

  15. #15
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: ADO.NET Can't Open Database File

    Quote Originally Posted by Jacob Roman View Post
    Crap, no wonder. Changed that code to this: myConn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source = Database1.accdb") and it worked! So theres no way ADO.NET can open such files ehy?
    That IS ADO.NET. ADO.NET is the .NET data access library, so basically anything under System.Data or anything that inherits or implements types under that namespace. That code is using the System.Data.OleDb.OleDbConnection class so it IS ADO.NET. ADO.NET supports various providers by default (SqlClient for SQL Server, OleDb for OLE DB data sources and Odbc for ODBC data sources) and third parties can implement their own dedicated providers too, e.g. Connector/Net for MySQL and ODP.NET for Oracle. If you choose OleDb then you have to specify an OLE DB provider, which is nothing specific to do with .NET. There are OLE DB providers for all manner of data sources. When you say:
    So theres no way ADO.NET can open such files ehy?
    I'm guessing that you actually mean the Jet OLE DB provider or perhaps the SqlClient ADO.NET provider, rather than ADO.NET itself.

  16. #16

    Thread Starter
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    Re: ADO.NET Can't Open Database File

    Quote Originally Posted by jmcilhinney View Post
    the SqlClient ADO.NET provider
    Yep that one. Was curious if I could use that with these.

  17. #17
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: ADO.NET Can't Open Database File

    https://docs.microsoft.com/en-au/dot...tframework-4.8

    Quote Originally Posted by Microsoft Docs
    The System.Data.SqlClient namespace is the .NET Data Provider for SQL Server.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width