Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Unhandled exception on basic db.Query() Token: b77a5c561934e089

$
0
0

I know this issue has been covered before, but after nearly 10 hours of reading other posts, documentation and trials, I am at a loss. I am new to .Net and C# so I apologize if this is trivial to others.

I am receiving the following error:

An unhandled exception occurred while processing the request.

TypeLoadException: Could not load type 'System.Data.Common.DbProviderFactories' >from assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

WebMatrix.Data.DbProviderFactoryWrapper.CreateConnection(string >connectionString)

On line #9 below: @foreach...

@usingWebMatrix.Data;@{var dbconn =Database.OpenConnectionString(@"Provider = .NET Framework 
    Data Provider for OLE DB; Data Source = C:\Users\...dbName.accdb");string selStr ="SELECT * From EquipList";}<table><tr>@foreach(dynamic row in dbconn.Query(selStr)){<tr><td>@row.recordID</tr>}</table>

StackTrace:

System.TypeLoadException:Could not load type             'System.Data.Common.DbProviderFactories'from assembly 'System.Data,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089'.
at WebMatrix.Data.DbProviderFactoryWrapper.CreateConnection(String
    connectionString)
at WebMatrix.Data.Database.get_Connection()
at WebMatrix.Data.Database.EnsureConnectionOpen()
at WebMatrix.Data.Database.<QueryInternal>d__0.MoveNext()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at WebMatrix.Data.Database.Query(String commandText,Object[] parameters)
at logCalc.Pages.Test_Page.<ExecuteAsync>d__0.MoveNext()in
    C:\Users\...\Pages\Test.cshtml:line 18---End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Razor.RazorView<RenderPageCoreAsync>d__16.MoveNext()---End of stack trace from previous location where exception was thrown ---

The Database.OpenConnectionString was originally in my index.module, but  when I began running into trouble I moved it to the header to simplify. I have confirmed that System.Data.Common.dll and WebMatrix.Data.dll are included and recognized. Based on the stack trace, it appears that the connection is being established, but the failure occurs when the query is pushed.  Or am I reading it wrong?  Any suggestions?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>