+ 1

How to create a database driven C# desktop app?

I am a newbie in desktop programming. I am trying to develop a desktop application using WPF. I am not being able to figure out how a database driven native application works. My questions are: 1. How do I connect to the remote database from the app? 2. How does the entire system work if I want to distribute my app as a standalone desktop app? How do I make my app to interact with remote database on client's machine?

29th Aug 2020, 11:03 AM
Subin Gyawali
Subin Gyawali - avatar
9 Réponses
+ 1
It is possible. Create you wpf application, start with local database Use sqlconnection, sqlcommand to query database. http://csharp-station.com/Tutorial/AdoDotNet/Lesson04 Now this wpf application does not need a database client to be installed. It only needs the sql-libraries. The thing that connects the application with the database is the connectionstring. You can compose the connectionstring in such a way that it connects to a local database. But you also can compose the connectionstring to point to a remote database. In that case the database should have an user that is allowed to access the database remotely. And a routers that allow this request to pass. All this has tons of security issues, you do not want unauthorized users to be able to access the database and corrupt something or enter false information. for example Mariadb https://webdock.io/en/docs/how-guides/how-enable-remote-access-your-mariadbmysql-database https://mariadb.com/kb/en/configuring-mariadb-for-remote-client-access/ https://mariadb.com/kb/en/connecting-to-mariadb/ Another option is create a webclient on the server and let the wpf application connect with the web-client.
30th Aug 2020, 11:02 AM
sneeze
sneeze - avatar
+ 3
I cannot say the exact specifics of how it's done, but as far as I know it's done similarly to local database, with only difference being data source in connection string. You need to figure out what's the external address of your server, it will be same whether you are accessing the database on same machine or from app deployed on different device.
29th Aug 2020, 11:48 AM
BlazingMagpie
BlazingMagpie - avatar
+ 2
I have figured out how to connect on my local system. It needed to install a mysql connecter on my system. What if i want to give it to someone to use it, do i have to manually install the connecter on his/her system? I don't think desktop apps work this way.
29th Aug 2020, 12:52 PM
Subin Gyawali
Subin Gyawali - avatar
+ 2
Thank you so much sneeze for answering in the way i wanted. 😊
30th Aug 2020, 5:08 PM
Subin Gyawali
Subin Gyawali - avatar
+ 1
I think SQLite is what you are searching for. But I'm not entirely sure
29th Aug 2020, 12:37 PM
Miroslav Nikolov
Miroslav Nikolov - avatar
+ 1
SQLite you can use it in c++ and i have worked with this library to modify a database
29th Aug 2020, 12:47 PM
Harsh Sharma
Harsh Sharma - avatar
0
I think you should write a program that interface with both computer and share information with both
29th Aug 2020, 1:02 PM
Harsh Sharma
Harsh Sharma - avatar
0
Or you should check out Angular+Nestjs provided by sololearn where you can how to make a app and interface with a database and create a app I would prefer you to checkout that lesson and your problem will solved I hope that lesson will help you! 😊
29th Aug 2020, 1:08 PM
Harsh Sharma
Harsh Sharma - avatar
- 1
Search on Google
29th Aug 2020, 12:30 PM
Harsh Sharma
Harsh Sharma - avatar