Aug 11th, 2021, 11:54 AM
#1
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:
Option Explicit On
Option Strict On
Imports System.Data.SqlClient
Public Class Form1
Private myConn As SqlConnection
Private myCmd As SqlCommand
Private myReader As SqlDataReader
Private results As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
myConn = New SqlConnection("Data Source = Database1")
'Open the connection.
myConn.Open()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Create a Command object.
myCmd = myConn.CreateCommand
myCmd.CommandText = "SELECT * FROM Table1 WHERE ID = " & TextBox1.Text
myReader = myCmd.ExecuteReader()
results = results & myReader.GetString(0) & vbTab & myReader.GetString(1)
Label1.Text = results
End Sub
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.
Last edited by Jacob Roman; Aug 11th, 2021 at 12:13 PM .
Aug 11th, 2021, 01:30 PM
#2
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.
Aug 11th, 2021, 02:56 PM
#3
Re: ADO.NET Can't Open Database File
This is the error I received with the original way
Attached Images
Aug 11th, 2021, 02:59 PM
#4
Re: ADO.NET Can't Open Database File
So I tried with this new code here:
vb.net Code:
Option Explicit On
Option Strict On
Imports System.Data.OleDb
Public Class Form1
Private myConn As OleDbConnection
Private oledbAdapter As OleDbDataAdapter
Dim ds As New DataSet
Private results As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
myConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.12.0;Data Source = Database1")
myConn.Open()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
oledbAdapter = New OleDbDataAdapter("SELECT * FROM Table1 WHERE ID = " & TextBox1.Text, myConn)
oledbAdapter.Fill(ds)
oledbAdapter.Dispose()
results = ds.Tables(0).Rows(0).Item(0).ToString + Environment.NewLine + ", " + ds.Tables(0).Rows(0).Item(1).ToString
Label1.Text = results
End Sub
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.
Aug 11th, 2021, 03:16 PM
#5
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.
Aug 11th, 2021, 03:23 PM
#6
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 **************
Aug 11th, 2021, 03:32 PM
#7
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.
Aug 11th, 2021, 03:44 PM
#8
Re: ADO.NET Can't Open Database File
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
Aug 11th, 2021, 03:52 PM
#9
Re: ADO.NET Can't Open Database File
Originally Posted by
jdc2000
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 **************
Aug 11th, 2021, 03:55 PM
#10
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
Aug 11th, 2021, 04:49 PM
#11
Re: ADO.NET Can't Open Database File
Originally Posted by
wes4dbt
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
Aug 11th, 2021, 07:56 PM
#12
Re: ADO.NET Can't Open Database File
Interesting choice in provider, Microsoft.Jet.OLEDB.12.0, try Microsoft.Jet.OLEDB.4.0;
Aug 11th, 2021, 08:05 PM
#13
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.
Aug 11th, 2021, 10:04 PM
#14
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?
Aug 11th, 2021, 10:14 PM
#15
Re: ADO.NET Can't Open Database File
Originally Posted by
Jacob Roman
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.
Aug 11th, 2021, 11:28 PM
#16
Re: ADO.NET Can't Open Database File
Originally Posted by
jmcilhinney
the SqlClient ADO.NET provider
Yep that one. Was curious if I could use that with these.
Aug 11th, 2021, 11:56 PM
#17
Re: ADO.NET Can't Open Database File
https://docs.microsoft.com/en-au/dot...tframework-4.8
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
Forum Rules
Click Here to Expand Forum to Full Width