SQL connection in UWP app - sql-server

I have am existing project that runs on windows, mac, ios and android. I'm looking for a way to make a windows phone version, but I can't figure out how to use SQL. My current code base is very large and I can't "switch" to using EF. How can I get access to databases in UWP?

If you want to connect a local database, for example the SQLite, there are implemented libraries could be used do this stuff:
A Developer's Guide to Windows 10: (10) SQLite Local Database
If you want to connect a server-based database, for example, the SQL Server database, unfortunately, there is not a built-in API like ADO.NET that could be used to connect the SQL Server directly. And for a workaround, you would have to utilize a middle layer for example, the WCF Serrvie:
How to access data from SQL Server database in Windows Store app, although this sample is written for store app, the used approach is the same for UWP application.

You'll not be able to connect directly to a Microsoft SQL Server database. Instead you'll need to make some type of Service layer that communicates with the database and your phone app would need to communicate with that. For more information on how to do that see the code same and the video that Microsoft has hosted here:
https://code.msdn.microsoft.com/windowsapps/How-to-access-data-from-5f2602ec

Related

How to sync Firebird with SQL Server database

I have a desktop app which uses a Firebird database. And it works fine, yet I want to also have access to that data online.
So I thought it might be possible to sync the data between Firebird and SQL Server. I know there is a tool called dbconvert but its quite expensive.
Any other solutions which come to your mind? Thanks!
You do not need to change the database. If you want to access your desktop app online you can, for example, place your desktop APP + firebird database on windows server and create a access through RemoteApp. Then you can accessed your application from anywhere (if the client OS can RemoteApp and online)
update
You can place application and database on a different type of server if you will reach them through some "remote desktop".

SQL access from a Windows 10 Universal Application

I'm trying to make an application for my company which will run on Windows 10 tablets connected to a main server over the internet via a VPN. I have the VPN and devices established and am trying a sort of "Hello World" with a tablet.
Here is my problem: My app will require access to the SQL Server running on main server hosting the VPN.
The SQL Server is already configured to allow access over the network and has been tested. If I write a simple WPF application, I can run it from the tablet and the SQL connection works perfectly.
So why is it a problem?
Because for the life of me I can't figure out how to connect to an SQL database from a Windows Universal Application. I'm using Visual Studio 2015 and the "Blank App (Universal Windows)" solution template. The System.Data.SqlClient namespace is not available by default, no framework assemblies are listed when I try to add a reference, and when I browse to the System.Data.dll to add it manually, I get other errors.
The above makes me feel like I'm going about this wrong; database access is a basic need for an application and shouldn't be this hard to implement. Can anyone tell me how to go about it?
AFAIK you can't directly connect to a full blown SQL DB from a WUA. Only to an SQLite one.
Similar question with more detailed answers-
Universal store app getting data from server
There is a class called SqlConnection which you can use to connect to a database that does the same thing.
Here is an example I found in msdn.
SqlConnection sqlCon = new SqlConnection("Data Source=(local);Initial Catalog=Test;Integrated Security =SSPI;");
Or you can create your own api on your server and connect to it using ajax methods like XMLHttpRequest().open('GET','stuff.aspx',true)

Database procedures and functions vs web services

In our development team we have:
4 developers
one application uses PHP and database Microsoft SQL Server 2008r2, except one using PowerBuilder instead of PHP and one using MySql instead of Microsoft SQL Server
All applications are database-centered, some of them are for general public, some are not.
Question is: for the procedures and functions shared by all applications, what does it make most sense to use, database procedures/functions or web services?
We could not find an agreement within the team.
Whatever you answer, please explain the reasons.
Webservices and Database Proc/Functions are two entirely different things.
Webservices are the services over the web, mainly used when a client and a server interact and client interacts with the server through web or HTTP or any other protocol.
Database proc/func - are created to interact with a login to a DB server.
In your case, if all the application are in the same domain... then you dont need to access through webservices and also it is a lot of overhead.
You can create a common DB server , where you can keep these proc/func and can be consumed by all.

Delivering Business Intelligence with SQL Server Analysis Services over the web

I have a cube developed using SQL Server Analysis Services (2005). Its hooked up to an excel front end.
At the moment users have their own logon to the reporting server and access the reports that way. However, it would be nice of they could access the reports over the web.
Are there options for this? I could upgrade to 2008 if there was a compelling case.
The reporting server runs on IIS, so you'd need to treat this as any other IIS server. Common practice is to not expose a database server directly to the internet, so you would want to have a separate server hosting reporting services, which needs another SQL license - if you are not already configured that way.
I'm not sure if you're asking for a way to connect a local excel to the cube, or if you're just wanting to get into the reports interface.
I highly recommend using the aspxpivotgrid to expose your cube data within a web app. http://www.devexpress.com/Products/NET/Controls/ASP/Pivot_Grid/
note: not an employee of developerexpress
CellSetGrid is an Open Source ASP .Net (c#) control, which offers pivot table like functionality.
[This used to be available for download in this site:
www.SQLServerAnalysisServices.com
Now the site does not host this control anymore. So I have uploaded the source of the control - CellSetGrid here.
http://www.box.net/shared/6gi0n79q6t
1) You can build the source
2) Add this as a Control in Visual Studio toolbox.
3) Drag and Drop control to a web form
4) Set the connection string to the cube
5) This will show all the dimensions and measure groups so you can drag n drop what you want to get a pivot table like functionality
SSRS is running on IIS, meaning user can access the reports over web with proper access permission.
Also you can build a custom ASP.NET application with ReportViewer control which is using almost the same report file used in report server.

Silverlight SQL 2005

I want to allow a user to provide their SQL login credentials, and display local SQL tables, stored procs, etc. in a listing. Is this possible? Note: I do not want to install some local, small SQL variant. I'm talking about the full version of SQL 2005+ that's already sitting on a developer's workstation.
Silverlight provides no mechanism for connecting to a SQL Database directly. You either need to provide a set of web services to interface with your data source or use ADO.NET Data services.
Connecting to a local SQL database using Silverlight alone isn't possible.
Something I almost missed is that you don't want to connect back to a database on the web server. You want information about a possible sql server instance on the user's (developer's) local machine. That isn't possible from within Silverlight alone.
I had thought you might be able to send the credentials on to the web server, have it dynamically generate a connection string, and then use the information_schema views to return lists of tables and views like any other data source. But that won't work.
However, in that scenario the web server is essentially acting as a proxy for your silverlight app. You might be able to build something else to act a proxy instead. Perhaps a small clickonce winforms app. That would install from a web page via hyperlink, so you could craft a link to install it on the page hosting your silverlight app.
With silverlight you cannot access the local machine/network resources. you will need to use wpf/xbap.

Resources