Using Sql with Windows Store - c#

I've found a few Google searches on this topic but nothing that really helps me.
Maybe because I don't understand what's happening.
How do I connect my Localdb using WA to a windows store application and how do i get the data from it with C#. Like "SELECT * FROM Table"

There is no direct way, you need to create a separate app that provides WCF endpoint that process all requests to the database and returns data to the client in this case this windows store app. You can create a windows service that provides such endpoint and in that service you implement all communication with database and provide API to the WSA(windows store app) through WCF

Related

How to connect windows service with UI configuration app?

I need to have a windows service that is configured with simple UI. I understand, that I need to create an API for windows service and use it in separate desktop application. But whatever I google I just got "you can't create UI to windows service" or info about webservice. I found this https://www.codeproject.com/Articles/1159908/Yes-I-Know-But-I-Still-Want-a-GUI-for-my-Windows-S but this seems to be a pretty bad workaround, because I can't use already started service in my GUI using it. What I need is some code, explaining how to create a connection between these two applications

Sharing Settings from WPF to Windows Service

I have a WPF application that should have been designed as a service since I realized that when the user logs out, the application closes. The WPF side has just a few settings such as DB name / password, OAuth token that is needed by the service. What is the best way to transfer that info from the WPF view to the Windows service? I had thought I would use registry settings, but it looked like that is getting phased out with UWP so I figured I would learn what the new "right" way was.
I would of course not want to store DB info in a plain text file.
What is the best way to transfer that info from the WPF view to the Windows service?
You could basically create a new Windows Service (.NET Framework) project in Visual Studio and move your current code over to this one.
For more information about how to create Windows services, you should check out the documentation on MSDN:
How to: Create Windows Services: https://learn.microsoft.com/en-us/dotnet/framework/windows-services/how-to-create-windows-services
The service may connect to the database in the same way that the WPF application does since both are based on the same version of the .NET Framework.
If you want to share data between a client app and the service, you could for example use a database. You might use a local database or a plain file if the service and client app are deployed onto the same machine, or you may use a remote database if thet are not.

C# using WCF when sending rows of data from online db to local db to online db

Good day, i have basically no experience in sending information over the internet, so excuse me if this is a little to DUH for you, i am trying to better my understanding.
What i have is a mysql database hosted somewhere on the WWW which is populated with a web application, i also have a local database stored on my ..local machine, which is populated via a windows form created in C#.
All of the above works like a charm.
What happens is, the web site creates some data in ONLINE_TABLE_ORDER.
The local app does some dark magic (based on data in ONLINE_TABLE_ORDER and populates TABLE_1 in the local mysql database, then TABLE_2 stores a bunch of data based on whats going on in TABLE_1.
On the click of a button its time to send ALL the data from TABLE_2 to ONLINE_TABLE_STATS which is the online mysql database and keeps updating the same table for statistical purposes.
What i need to do, is to send the rows of data from ONLINE_TABLE_ORDER to the local database, the C# windows form will then automatically pick up the details and populate various controls, when all is said and done the application will then need to send rows of data from TABLE_2 to ONLINE_TABLE_STATS where the web form will then pick up this new data and display it accordingly.
That being said, i now need to figure out how to go about sending all of this.
This is where WCF and web services comes in.(i guess, its what information i have managed to wring out of google).
Now i would like to do this via services to maintain data integrity (local internet is shitty, and could cut out at anytime, so i am hoping that web services can help with that).
Finally, this is where my understanding needs some TLC,
1: Can a WCF service form part of my C# application; in that the application pulls data from the web based mysql database and then pushes data back to that database?
2: Can a WCF service run by itself from within the local application? or does the server on which the web database is hosted also need a WCF service running?
3: Does only the online server need a WCF service running? (create an applet in C#?)
4: Is this all overkill and i dont actually need any services when a simple bulk insert statement suffice? (remember shitty internet).
Remember, i would like the service to handle
ONLINE_TABLE_ORDER --> TABLE_2 --> ONLINE_TABLE_STATS
No, i am mostly self taught and am really eager to learn more about this, even if it is overkill; as i have been checking out tutorials and blogs, none have actually given me sufficient answers to the above.
Most, deal mainly with application to hosted database but have yet to find one from database to database which is what i am trying to do.
So in closing, if you can help my understanding as well as leave some kick ass links to great reading material, id really appreciate that. If you lovely individuals require anymore information about the how's or why's, leave a comment and ill edit my question.
I think you need to comunicate from your CSharp app to your online database via web services like you said. So, you need a WCF service hosted online with access to the database (or other kind of service, like an api in the online web site who have access to the databse). Also you need a service client in your CSharp app who comunicates with the online server.
So answering to your numbered questions:
A WCF can be hosted in a C# application (called "self hosted service" or something like that) but it does not resolve your problem. Your CSharp app should be client not service.
Basically the same answer than before
The online server need some kind of service who interacts with the database listening to http request. So, WCF is a good alternative. You can use another kind of web service, like a api service in the web application
In MY OPINION i think you need a service who controls security, data transport and a lot of stufs

Database change notifications to a windows service?

I am using WebAPI to push some data in to the database.
A windows service operating in the same server has to get notified when a data is inserted by the WebAPI
I have seen this SO question which suggests using Service Broker or SqlDependency but the question seems to be asked quite a while ago.
I googled out but could not find any simpler solutions. All I wanna do is when a new data is inserted to Database, a function in the the windows service should fire.
Do we have any alternatives or a much similar solution in WebAPI - Windows Services context ?
There is a way. I don't like it very much, but you can use CLR Integration.
You can use it to write a trigger: https://msdn.microsoft.com/en-us/library/ms131045.aspx
It can contact external resources setting the correct permissions: https://msdn.microsoft.com/en-us/library/ms345101.aspx
Then you can call your service via socket, or make it a webservice. But you need c# programming skills.

getting data from database in windows 8 app

I am building a windows 8 app which requires me to get data from a remotely hosted server. Which API can I use to get the required data? I am using c# and xaml. I basically want to communicate with Microsoft SQL Server Analysis Services. ADOMD.NET cannot be used as windows 8 store apps donot support it.
In a Windows 8 app, we can specify for example a connection string to read out data stored in a server-side database. Not only would this be a huge security risk (imagine your connection string being on the thousands of devices where your app is downloaded!), it would also be pretty useless to have it there. WinRT has no knowledge of talking with a (remote) database. This means no ADO.NET or LINQ-To-SQL classes are in the API.
windows 8 style apps dont have out of the box functionality to contact to a database. so you need webservices to conect at a remote database.
If you have a database on a web server for which you can write an OData service, then that's an option. You can use the OData Libraries
I hope http://blogs.msdn.com/b/phaniraj/archive/2012/04/26/developing-windows-8-metro-style-applications-that-consume-odata.aspx will help you.

Categories

Resources