0

I am develping an UWP app in visual studio 2017. I want to read .mdb and access database files for my analysis. I have created two projects in same solution. One with UWP and other with C# .Net. I want to share the C# .Net using reference project approach where I should be able to call a program to read database.

I am new to the overall concept. Can someone please share the example to get input from OLEDB code to UWP application? I am not able to get it working.

I am referencing following article. https://learn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-migrate

Sir Rufo
  • 18,395
  • 2
  • 39
  • 73
  • Hello, I think you can go to visual studio -> File -> New -> Project -> Class Library (.Net Standard). This will create a class library project where you can write a code which you will be able to use in WPF and UWP – Sergey Anisimov Nov 25 '18 at 03:42
  • The important part is wich Framework is targetted. WPF targets usually the .NEt Framework, something beyond 3.5 or so. Meanwhile UWP is WPF targetting .NET Core, with some add related additions. i think the article is about sharing the code between a UWP app and another .NET Core targetting Programm. However there is the superset of target: .NEt Standart. .NET Framework, .NET Core and to some degree even mono are just **implementations** of that standart. – Christopher Nov 25 '18 at 05:16
  • Possible duplicate of [Read MS access database file (.mdb) in UWP](https://stackoverflow.com/questions/40146689/read-ms-access-database-file-mdb-in-uwp) – Sir Rufo Nov 25 '18 at 07:16

1 Answers1

0

I honestly have to admit I was not aware of this ability before today, but I will try to do my best to describe it.

First We need to differentiate between 3 things here:

  • .NET Standard
  • .NET Framework
  • .NET Core

.NET Core and .NET Framework are both implementations of the Standard - and a whole lot on top of that. WinForms was never part of the Standard. It was the .NET Framework going "above and beyond". Wich also explains why .NET Core could so easily drop it. Now apparently besides targetting a .NET project agianst .NET Core, .NET Framework or Mono, you can apparently also aim it against .NET Standard.

That means it can be used in both .NET Core and .NET Framework applications, but you only get exactly what was defined in the .NET Standard - none of the additional stuff. And you also have to manually change it in the project properties, there are not (a lot?) of default templates for it.

WPF apps must target .NET Framework. And UWP is little more then WPF + some app related stuff, when you target .NET Core. So they both must target a specific Target Framework.

Unfortunately the OLEDB classes were never part of .NET Standard. If you look at the "Applies to" section, it only applies to the .NET Framework and one version of Xamarian.

If you look at the SQL related classes, it applies both to Core and Framework - but not the Standard. So you could use them in Project targetting Core or Framework, but not the Standart. It appears the DB related classes are just not nearly generic enough to have made it into the Standard.

Mind you the abstract baseclasses for both are in the Standard 2.0. Just their concrete implementations are a minor detail. So you could write your own DB Access clases based on those abstract classes and Interfaces, if you really felt like it.

Klaus Gütter
  • 11,151
  • 6
  • 31
  • 36
Christopher
  • 9,634
  • 2
  • 17
  • 31