Universal store app getting data from server - sql

I want to build an app that gets data from a server and it displays it in xaml. I'm new to universal programs and in windows store apps in general. I haven't found anything useful yet as ms sql solutions require libraries that is not allowed for universal store apps :(
P.S.: The answer in how to connect sql server 2008 R2 with windows store application did not answer my question, but Jeffery's answer did.

You can’t connect to a MS SQL Server directly from the Windows App. The common way is host a data service and the app query the data through the REST API.
App -> data service (e.g. OData service) -> database (e.g. MS SQL Server)
In this case, you can deploy the SQL Server Data Service on IIS.
How to: Deploying OData Services using IIS & SQL Server
Then you use the HttpClient to retrieve the data from service.
Similar Question:
Windows phone 8.1 app connect with a database

Related

Windows Phone 8 access to SQL remote Database

I'm trying to develop a WP8 app, and I have a free online sql server (not windows azure).
How can I Access the Database from the phone app?
I tried a local WPF sevice and it worked, but it won't help if I'd like to upload the app to the store.
Thanks for the help!
As far as i'm aware, you can't access the database directly, you need a proxy web service for this, i recommend you to look at OData, REST APIs and also to JSON or XML to transfer your data from the database to your app.

How to connect to remote database with windowsphone

In my app, I want to read a remote sql database. After spending some hours on searching the net, I found out that this can not be done with sql commands but that it needs a webservice wrapper I.E WCF or ADO.net
Are there (and where) any examples on how to read/write records to a remote database server using windowsphone.
Thanks,
Bart
Your best option will be to use WCF Data Services with an AD.NET Entity Framework model (there even is a client for Windows Phone). Beware that the Windows Phone client by default does not use compression and does not use the compact json format. UPDATE: Latest client/server parts now use json with Windows Phone

Sync Framework: SQL Server to SQL Server To SQL Express

I'm very new to Sync Framework, Still exploring different possibilities. Here is my Scenario.
We need to have an application (SQL Server and ASP.Net) which is hosted on our web server. Users can register and interact with it online. Another Copy of the application will be installed on our Client's Intranet server. Users can be registered over LAN on this server.
A third copy of the Application (SQL Express) will be installed on various laptops and windows 7 tablets. Users will use the application remotely without connectivity to LAN or internet. Once the device is back in network, it will sync data with the LAN server and LAN Server will sync to the Internet server.
I intend to do this using WCF services and Sync Framework for the sake of security, however I'm open for suggestions. Can someone please suggest me the correct way of doing this and point me to some tutorials samples to do this. I've been struggling with samples available online (mainly this one http://code.msdn.microsoft.com/Database-SyncSQL-Server-e97d1208) for a while and still have no success ..
Feel free to shoot any questions and I will answer them as best as I can.
have a look at this link and ignore/substitute the Azure specific stuff with SQL Server...it has a good discussion on the WCF specific components... Walkthrough of Windows Azure Sync Service Sample

Create Windows Desktop widget which connects to SQL Server

I want to create a desktop widget for Windows 7.
My requirements are below
I can provide SQL Server login credentials
It should connect to SQL Server
List out all the jobs in the server
Can anyone guide me on how to do this and where to start from?
Perhaps create a middle layer, that returns XML/JSON/HTML/..., that your widget can call through HTTP?
SQL Server 2005 supported native XML web services using SOAP/HTTP endpoints.
It's been deprecated in sql server 2008.
Your best bet would be to create a small HTTP server that acts as a broker between your SQL Server and desktop widgets.
You can find C# example code for HTTP server on Google.
http://www.google.is/search?hl=is&q=c%23+simple+http+server
Then let your widget just call the HTTP server for the information you want to display.
PS: Make your HTTP server log on and talk to the SQL Server, don't send database credentials (or ay other for that matter) over HTTP.

Windows CE - Database

I need to setup an application to scan a barcode from a packing slip and the associated fulfillment items on a windows CE 5.0 device and update the inventory on the server. I'm using VB.NET. However, what is the best way to interact with the database? Integration Services, ADO.NET, RDA... etc... it's a bit overwhelming trying to figure out what I should use to interact with the database. It's currently an Access database, but I imagine I'm probably going to need to migrate it to SQL Server or SQL Server Express.
I'd also need to print the packing slip to a network printer from the device. Is there any way to do this?
Sql CE is an excellent choice if your devices have to function for stretches in a disconnected state (i.e. not connected to the server). If you do use Sql CE, however, I strongly recommend not using RDA to persist local changes back to the server database (see this answer). In any event, RDA merge replication would require your server database to be Sql Server.
If your devices are always connected to the server through a wireless network, then you do not need a local database on the devices at all. Your devices can upload and download data through ASP.Net web services running on the server. Using DataSets for this communication is a good choice, since they are essentially database-agnostic (and thus your PDA code won't particularly care what database you're using on the server).
The web service approach will also let you handle the printing requirement. The PDA would send the relevant information to a web service method, which would then handle printing to the network printer.
My recommendation is to use SQL Server Compact edition (http://www.microsoft.com/Sqlserver/2008/en/us/compact.aspx) for storage engine, and ADO.net implementation of SqlCe in System.Data.SqlServerCe namespace (http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.aspx) for code interaction. They are very well integrated with Visual Studio 2008, including designer support of strong-type dataset and run-time examination of data content on device etc.
No idea about the printing.
In all today scenarios, I would recommend using SQLite. It is the most used database today. Don't bind yourself to an database ecosystem. Just go here and search for "Precompiled Binaries for Windows CE (.NET Compact Framework)". Then you have a SQLite.Interop.*.dll and the System.Data.SQLite.dll. The SQLite.Interop.*.dll has to be placed and deployed besides your EXE file. The System.Data.SQLite.dll is the managed wrapper, that you have to reference in your project. Example: Create SQLite Database and table
SQL Server Compact is not compatible to most mobile platforms like iOS, Android and so on. Microsofts support for old target platforms is poor, leaving Windows CE with only SQL Server Compact 3.5 SP2 where you don't have some essential SQL functions like "LIMIT". Databases generated on the Desktop OS (> Windows XP) will also need to be converted on the device (long delay, when you first open the database), because MS is using different code pages on desktop and Windows CE.
This is Microsofts statement about RDA:
Because of design limitations, remote data access (RDA) will be removed in a future release. If you are currently using RDA, you should consider transitioning to Microsoft Synchronization Services for ADO.NET. If you were planning to use RDA in a new application, you should instead consider merge replication or Sync Services. Note that Sync Services is currently available only for the Windows Desktop Operating System.
Best way to interact with the database is just build the database on the server, compress it als deflate (available under both Desktop and Compact via System.IO.Compression) and send it to the device in whole. Plain and stupid. Most devices have poor import performance, so doing the import locally may take too much time, even if you have a fancy sync framework.
To transfer the database you can use a WCF service or just any web server using a HTTPS GET. Like so:
// ppp_peer is in most cases the active sync connected pc
string url = #"https://ppp_peer/export/database.db.gz";
string html = string.Empty;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (FileStream fs = new FileStream(stream))
{
// Decompress your database here
}
To ORM your POCO objects just use something like https://bitbucket.org/twincoders/sqlite-net-extensions
However, if you have WLAN access everywhere, I would consider writing a browser application and using the mobile browser together with a web server for your needs. Just keep in mind, that Windows CE 5 based devices don't come with HTML 5 support out of the box. If you have a choice consider switching to a Android based device.