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
Related
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
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.
So I am currently doing some research for creating iPhone and Mac applications for my company and perhaphs other small businesses. I have found god knows loads and loads of books on cocoa and iOS development, but on the side of SQL server things get a little more shady. I have seen all kinds of products online who claim to be the best SQL driver and to be the simplest and performance enhanced way of adding a relational database to your cocoa app. I have currently been and still create desktop applications under windows and we extensively use our databases for almost all applications and reports we build. We have iPads and iPhone all around our company and I could really bring some innovative apps to our table if we could have some of our workflows or reports on the iPhone or iPad. I cannot seem to find a viable SQL driver like using visual studio under widows. Is there a obvious solution that I have missed or do developers just not deal with enterprise projects with relational databases? We as a company have the capabilities to create what ever web or server needed to get such a project underway but before I do I want to make sure I can work with our existing database as I could with visual studio, any ideas or suggestions are welcomed.
I guess this is one of reasons why is there sooo little enterprise-class software on Macs... As a first candidate I would consider FreeTDS to access SQL Servers. It has headers and libraries that can be linked in XCode as far as I know.
As you mentioned in your post and comments, you do have great design in your mind. For having an application to compatible with any mobile device, the best application design would be to have your application running on as cloud service connected to specific cloud DB while application is talking to it over any exposed interface.
With Windows Azure your application can run as Cloud Service while using SQL database. In your cloud service you can have WCF endpoint exposed which can serve connection to your SQL Database and provide specific data you are looking for. This way your cloud application will be able to serve any mobile device as long as you can make connection to secure WCF endpoint and get back the data. In WCF you not only get XML data, you can pass much more complex results and process in the device as if needed.
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.
I'm new to silverlight and I'm porting from asp.net 2.0. I have done many data binding applications in asp.net where I use sql server 2005 and use it's tables and access them via sqlconnection object and perform all kind of database related functions. Can anyone tell does silverlight 2.0 supports such kind of facility. If so can I use any database server, if not is it through web services? can anyone point me some good place to start with.
No you can't connect directly to a database server. You need to use a web service. However to simplify things you can call a data web service such as SQL Server Data Services or Amazon S3. Otherwise use REST.
Silverlight is a client side technology. You can't access a database on the server directly. You have to use a layer in between, like webservices. For a nice tutorial on how to do that, check http://weblogs.asp.net/scottgu/pages/silverlight-2-end-to-end-tutorial-building-a-digg-search-client.aspx