How to access the same database file between two projects in a Visual Studio Solution?

prabha_friend

Prabhakaran Karuppaih
Local time
Today, 17:11
Joined
Mar 22, 2009
Messages
1,038
ProjectA: C# class library project
ProjectB: .Net MAUI Blazor Hybrid project
 
Your question was under the wrong topic heading. Moved it.
 
But the database file is accdb only ;)
 
If the database to be shared is a more or less standard DB, either .MDB or .ACCDB, and is a proper back-end file with no code that you would need to invoke, you should be able to access it using your system's DAO reference library files. For instance, on my system that uses Office 2021, I would probably try to reference the Microsoft DAO 3.6 library. The version number might change depending on Office version.
 
Sorry Doc. Now only I searched about accdb and visual studio. We cannot migrate accdbs using Entity Framework Core. so now my question is: "How to use an sqlite3 database file between two projects inside a visual studio solution". Now it has become a complete "Other Software". Thanks Doc.
 
Jet/ACE are ODBC compliant. To get data from an .mdb or .accdb, your code needs to use ODBC to make proper connections. I think DAO is only used within VBA. You probably need to use ADO.
The problem is building the connection string. Where the database file (any database file) would be residing after deployment and How to access the exact same file... is where the problem is.
 
If you don't know where the database is then that is a problem. Do they move around? Because if they don't then you can have a setup procedure that locates the database so that the app can build the correct connection string.
You know... In MAUI. The target machine may be an Android or an Iphone or a PC. PC has drives and what about other devices...
 
Files are files. They're just buckets of bits. Using a file is different and these .accdb's are to be used to provide data.

Which translated into words that we ignorant people can understand, what would it mean?
 
It's not my game
And it's not stupid at all
Especially because it responds to a request from colleague prabha_friend
Of course, if you have a simpler solution, or less stupid, that's fine, let's hear it.
 
I don't think proposing a solution, even if you said there isn't one, can be considered aggressive
Don't worry about breathing, I do the ones I like: deep, short, long, a bit of everything.
 
I've linked to a post that provides a solution
That link also contains an example (source code) of a program that uses the UcanAccess library
So if you write "..yet you refused to elaborate.." you should know you're writing something untrue
Why?
 
I'd create a web API that both projects can access and be done with it.

If an .accdb file is what I must use, then I'd put the file in a Windows server. That way, if either of the projects sends an HTTP request, the server simply connects to the .accdb file, does its business and returns what you asked for.

If a sqlite database is to be used, same thing, but the server could be whatever, not necessarily Windows.
 
... is beyond me though....

You're not the one who has to think about how the system should be set up
The colleague asked some questions; if you know the answer, you can help him
Otherwise, save the ink
 
Sorry Doc. Now only I searched about accdb and visual studio. We cannot migrate accdbs using Entity Framework Core. so now my question is: "How to use an sqlite3 database file between two projects inside a visual studio solution". Now it has become a complete "Other Software". Thanks Doc.
_dbContext.Database.EnsureCreated() does the Magic!
 
So you're saying that MAUI can make Access run on your phone? I doubt it. If you can use a browser to get to a Citrix server or remote desktop, you can run Access "from your phone" but not "on your phone".

Why are you storing Access databases on a phone anyway? And why would you want to retrieve data from an Access database on MY phone and how are you going to turn on MY phone anyway?
https://www.access-programmers.co.u...-a-visual-studio-solution.334325/post-1968280
 

Users who are viewing this thread

Back
Top Bottom