Upload Data from .net Windows Form Application - c#

Sorry, if this sounds ignorant. Is it possible to SECURELY upload data from a Windows Forms app using an asp.net web service or some other method? If so, what is the general way of doing it?
I have never used web services before.
I have an IIS 6 server with .net 3.5 installed. I need to build this windows forms program, which will hold data in a local sql compact database. When the program has access to the internet, the user needs to be able to MOVE the local data to a database on the web server.
What ways can I go about doing this? Am I on the right track thinking about web services? I have also read a bit about Sync Framework, but I'm not sure if that is all that well suited for this.
Thanks for suggestions.
EDIT
I forgot to ask: Would WCF be a possible useful technology?

Yes. Just secure the web service by SSL.
WCF can be a useful technology too. You might also want to consider SQL Server merge replication.

Related

How to use Entity Framework Core with SQL Server in Xamarin Forms?

I'm trying to use Entity Framework Core with SQL Server (not SQLite) in a Xamarin forms app but I just can't figure it out! All tutorials explain how to use EF Core with sqlite! Are there any clear documentation or tutorials?
About connect to a Remote DataBase in Xamarin.Forms, I find one article that you can take a look:
https://xamarinhelp.com/connecting-remote-database-xamarin-forms/
You may be wondering why you couldn’t just connect directly to a database from your mobile app? The main reasons are:
Security
You don’t want your mobile client apps to have a database connection string with a username and password in it. It opens your database up to anyone. You can create a user with read only permissions and only allow access to certain tables, but they could still see all data in these tables. On an API, you can implement additional security checks and have authentication based on OAuth or an existing user management system.
Performance
Database connections weren’t designed to go over high latency connections. It is likely your database connection would keep dropping, forcing you to reconnect every time.
Control
With an API you can control the flow of data to and from your database. You can implement rate limiting, and monitoring of all of your requests. If you need to change business logic, or even what database or resources are used via each API request, you can do this on the server, without having to redeploy a mobile app.
Resources
With an API, you reduce the need for server resources. While you may have to setup another server to handle an API, the REST API is designed to be stateless and efficient. Scaling to many users in the future is easier with an API.

Access remote SQL Server database using webforms

I have sql server database in my web project (hosted over the internet). Now, i want to make a c# windows forms (or WPF) application that, i can access the same database(that is in my web project).
What is the best way to make that application? Which webservice technique should i use.
Any help link regard to this will be appreciatable.
Thanks
You can expose your data through a public API implemented in WCF, and call that API from basically any kind of .NET application including WinForms and WPF by using WCF as well. So, check out WCF (Windows Communication Foundation)

Good way of communicating between web and desktop app

I want my web app (running in a browser) to, at some point, communicate (bidirectionally) with a desktop app (in Windows), the client has installed in its computer.
What's an elegant and modular and simple way of doing this (with Java and C#)?
Not much information will be passed between the web app and the desktop app. Just something like "I was here", "Pick this from this point", etc.
I solved that problem by using a database on the network.
All communications where made trough the database.
Website -> DB -> User logged in <- DB <- Desktop
However, if no trusted information needs to be shared, you could consider just posting and reading some http headers to a common website, or a simple log file.
Greetings
I suggest you to use the backend part of your webapp, assuming that your app is based on some backend services.
You have two options:
Your desktop apps use the same services of your web app. You must use a class that mimic a web-browser to give the data (curl, ie). If your web app is based on AJAX push ( APE Server i.e ) use library that is able to run some javascript
Use a REST protocol, with a JSON format in your backend services. It's easy to manage and is supported by many client-side languages (java/c#/python....)
Use a specialized endpoint only for your desktop app,for C#, you can use WCF, that allow you, in one of his forms bidirectional communications. For JAVA, there are WSDL, DWR
My preferred solution is to decouple the web app in a front-end side and a backend side, that expose the services as REST that are used by the web app via AJAX.
If I need true bidirectional communication with other desktop app, I'll create a separate service / endpoint for it. (APE , WCF, ..)
I see several options to achieve part of what you are asking:
Besically you expose the relevant parts of your apps (web and desktop) via some sort of API and use that for the communication - for example DB and/or WCF (SOAP/REST/whatever).
BEWARE:
If you are after some sort of direct/interactive communication between both apps on the same computer then this won't be possible - at least not without some security related issues.
The browser executes your web app in a sandbox which doesn't allow for direct communication between the web app and the desktop... there are technologies which can help circumvent that (ActiveX, signed Java applets, some Flash technology called AIR etc.)... or you could host some webbrowser/control in your desktop app which in turn runs the web app... BUT basically I would recommend against using any such measures...
IF you really want to go this route then please describe your environment and goal with much more detail.

Accessing an SQL database from a Silverlight client (no web project)

I want to access a remote SQL database for my Silverlight client. I know that there are various ways to do this (Entity Framework model, Linq to SQL), but all of those rely on something in the web project (or, at least, all of the tutorials I've read do). What's unusual for me is that there is no web project, which of course prevents me from using various assemblies.
The only thing I do have which might be useful is a WCF service running on IIS, which will have less limitations (and I can add that as a service reference in my SL project). But I'm not even sure if this is a feasible option for this problem.
Any solutions or suggestions would be great.
Thanks.
Edit: Thanks for the suggestions guys, but here's a little more: I am making an individual XAP that is loaded into something else (someone else's project is importing and loading the XAP files), so I don't have access to the web component. The loader itself will be hosted within a website (at least, I assume it will be).
I already have a WCF service set up which is currently hosted in IIS, so I can potentially create something here. How? Well, it seems I can generate the ORM classes using SQLMetal.exe, and then import that code into the WCF service. This will allow the service to make calls to the remote database and have that data returned in C# classes. The perhaps I'll make those data classes as ServiceContracts and pass the data that way. What's the problem here? Well, to be honest, I'm not really sure how it would work. I mean, I call the WCF Service from the SL application, which does its thing. It then must contact the SL application (I have no idea how to do that part) and send along a load of data. It would be great if someone had has experience of this and would offer some suggestions. I know it's not really how you're supposed to do it, but I've drawn the short straw so I'm stuck with it.
Ok, so if I understand it correctly, you use a Silverlight application (XAP) which is started locally from a network share or something? Because why would you not have a web project when using Silverlight? (is there no server available to host it?)
But ok, when that is the case, you can access a WCF service from Silverlight. However it has some limititations. For instance you can only use asynchronous calls to the service, and you can only use WCF basichttpbinding as binding for the WCF service.
See: http://msdn.microsoft.com/en-us/library/cc197959%28v=vs.95%29.aspx
First, I would recommend you use WPF instead of Silverlight for this project. If you're not using this as a web client, then WPF is a million times easier / better.
But if that's not a possibility:
You can write a self-hosted WCF service and run it somewhere accessible. Self-hosted will allow for WCF connections to connect without the IIS necessary. In your self-hosted program you need:
Front end WCF defined
Back end SQL database
Depending on how smart this client needs to be, a BusinessLogic layer to transform the data from WCF to SQL.
Silverlight is sandboxed, so it can only access its own Web application. Therefore, your best bet is to include a WCF or ASMX web service in your web application that handles the DB access.
If you don't want to run a sandboxed UI on a Web application, you cannot use Silverlight but should use WebForms or Windows Presentation Foundation (WPF) instead.

Connecting to SQL Server Database C#-WinForms

I have a desktop app that I'm making and I want users to have to login before the program can be used to its fullest extent. I have created a database on www.winhost.com (where my site's hosted), but now I don't know what to do. I've been on google and msdn and I would like to know how to programmatically add new rows/colums to this new database which is currently empty. And how I can update the database with new account info/get information from it.
I'm not expecting code or anything, just maybe a few good simple tutorials or something, since I haven't found what I'm looking for yet...
Here is a beginners guide to accessing SQL Server using C#:
http://www.codeproject.com/KB/database/sql_in_csharp.aspx
Hope it helps :)
You probably want to add a web service to your website either through WCF or an ASMX file or maybe an ASHX file. Your desktop app would ping that service and ask if the user is registered. If so, it would unlock the app, otherwise it would ask them to register and hit another service method that would add the record to the DB.
The defacto technology to connect to databases in the .Net world is ADO.net
There are tons of tutorials on how to get started on the web...
This video is a good start: http://windowsclient.net/learn/video.aspx?v=30440
There are others on this topic on the same site.
A ADO.net book that I liked is "Pro ADO.NET 2.0", published by APress.
I hope to have answered your question. It is not very clear whether your question is about user authentication or updating the database...
If the problem is that you are not sure how to reach the database that is hosted on their
servers, the best may be to contact the hosting company's support.

Categories

Resources