WinRT System.Data - Connect to SQL - sql-server

Just want to make sure I am not missing something. There does not appear to be a WinRT System.Data. What I am looking for is System.Data.SqlClient to connect to SQL. Can a Metro App connect to SQL? If yes can a Metro App connect to SQL in a App Store compliant manner.

You are correct, System.Data is not there (I looked for the same thing when I first started messing around with WinRT). You won't be able to reference it either. If you want to talk to a SQL database you're going to need to use some kind of other protocol (WebService, SOAP, WCF, etc.).
There are ports for SQLite available that appear to be working which will give you a local DB option but not a server based one without using some kind of middle man to get to the DB.
As a side note, I personally would have liked to have seen a desktop Metro app that could connect to a SQL Express Database for instance but it's not currently in the cards without jumping through hoops.

Related

How to Connect Xamarin.forms PCL with SQL Server directly?

I want to know how to connect Xamarin.Forms PCL with SQL Server directly. I know accessing the database directly will not be secured. But that's not problem in my situation. I need to access database directly from Xamarin.Forms. I am using Visual Studio 2017. I have developed an app with Xamarin.Forms PCL.
In answer to your question, use Entity Framework Core and a connection string, directly to your database. That will enable you to connect directly to it.
Now, I'm going to spend the rest of this answer, why you shouldn't do this
You are giving a remote, unknown, complete stranger, complete, direct access to your database. Even if it's in a separated network, with completely trusted users, and not on the app store, you are still opening your database up to potential security breaches.
It is likely over an unreliable mobile connection or wifi. It will fail and drop out, a lot.
It will be incredibly slow
If you want to move that SQL server later or update, you will break every single client out there, while you send an update for your app.
You won't be able to easily add any logic, in between, to improve performance, or add business logic as needed.
Database corruption, another important and likely to occur scenario, as mentioned by Brandon above.
What you need to do.
Create a web api. It's easy to setup one with WebAPI with dotnetcore
The API connects to the database, the mobile client connects to the API.
Add authentication to your API.
And I go into some more detail in Connecting to a remote database here.

Interface .net MVC4 with SQL Server 2005/2008

My organization uses IMIS, a membership/event database that stores its data in our sql server 2005 db. I've been developing classes and service layers to interface with that data using - wait for it - asp.net 1.1, and my lord I am ready to make the switch to something a little more modern.
So after experimenting with CakePHP on the side, being a microsoft shop, I'd like to use MVC4 to take care of all of my future applications, but it seems that every tutorial I find on the subject uses an SQL Server Express instance - there doesn't seem to be much mention of connecting to a remote 2005 or a remote 2008 server.
Full disclosure, I have seen a few comments here and there mentioning that the name of the class and connection string and database all have to be related, but I haven't found any clear indication of what the rule of thumb is.
If anyone can give me some basic steps as to how to set this up, I'd be forever grateful.
Thanks.
If you have existing Database you want to connect to I would suggest using Entity Framework with Database First approach.
You probably could find many tutorials, here is the one particularly for Entity Framework + Database First + MVC:
http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/database-first-approach-in-entity-framework/

Hosting an Access DB

So I'm inexperienced in hosting DB's and I've always had the luxury of someone else getting the db setup.
I was going to help a friend out with getting a webpage setup, I've got experience in Asp.Net MVC so I'm going with that. They want to setup a search page to query a db and display the results. My question I have is in getting the DB setup and hosted. They currently just have the Access DB on a local computer. There is basically only one table that would need to be queried for the search.
What is the best approach to getting this table/db accessible? They would like to keep the main copy of the db on the local machine, so copying the entire db over to the hosted site would be time consuming, could the lone table needed be solely copied to the host? Should I try to convince them to make changes on the hosted db and just make copies of that for their local machines? Any suggestions are welcome, Again I'm a total noob when it comes to hosting databases.
Thanks
Added: They are using a MS Access 2000, and the page will have access restrictions. Thanks for the responses.
How about SQL Server Express? I think you can do a remote connect from Access and just push the data over from Access.
I wouldn't use Access on a web server in any case.
I would strongly recommend against access from web work, its just not designed for it and given that SQL server express is free there is no reason not to give it a go.
You can migrate the data over by using the SQL server upsizing wizard, here is a link for help on using that feature
http://support.microsoft.com/kb/237980
It depends on what you mean by web work? Access 2010 can build scalable browser neutral web applications. They can scale to 1000's to users. In fact, you can even park the web sites on Microsoft's new cloud hosting options, and scale out to as many users as you need.
Here is a video of an application I wrote in access 2010. Note how at the half way I run the same application including the Access forms in a standard web browser. This application was built 100% inside of the Access client. The end result needs no ActiveX or Silverlight to run.
http://www.youtube.com/watch?v=AU4mH0jPntI
So, the above shows that access can now be used to build scale web sites (you can ignore the confusing answers by the other two posters here they are not quite up to speed on how access works or functions).
However, for your case, I would continue to have the access database on the desktop. You can simply link to tables that are hosted on the web server. Those tables can exist in MySql, or sql server. As long as the web site supports external ODBC connections (many do), then you can thus have the desktop application use the live data from the web server. If connections to the live data at all times is a issue, then you could certainly setup something to send up new records (or the whole table) on some kind of interval or perhaps the reverse, and pull down new records on a interval from the web site (depends which way you need to go). So, connecting to MySql or sql server is quite easy as long as the web hosting and site permits external ODBC connections. I do this all the time, and it works quite well.
As mentioned, new for access 2010 is web site building ability but that does requite Access Web services running on SharePoint.
You don't need to upgrade to Access 2010. One option is to use the EQL Data plugin to sync the database up to the server. Then you can write an asp.net, php, or whatever application that queries the table using the EQL API and prints the results however you want. This kb article describes how to use the EQL API from a web app.
The nice thing is that the database is still totally usable (and at full speed) even when you're not online, and then you can sync the new data up to the web occasionally. It only uploads the changes, not the entire database every time, so it's fast.
Disclaimer: I work at EQL Data so I'm a bit biased. But this kind of use case is the whole reason the company exists.

Cocoa Touch & Sql Server

Is it possible to connect to Sql Server for the purpose of executing simple Sql commands within a native iPhone app?
If so, how does one go about it? I'm stumped. More generally, I would at least like to see how this is done with GCC.
Thanks in advance, Rich
My goal with this question was to create an iPhone application that could connect directly to an instance of SQL Server and execute SQL commands against that instance.
I don't believe for one second that this is impossible, but if it is possible, the solution requires more knowledge of C than I currently poses. This experience has shown me how much I take the .NET Framework for granted, and just how powerful and extensive the .NET Framework actually is. That such a connection would be so trivial in one framework, and so convoluted in another.
Being primarily a Web Developer, Web Services are well within my comfort zone. Initially I was not willing to consider them, as my secondary goal was that any solution I came up with should not require bespoke software on the server.
ALas, Web Services seem to be the most practical route for me at this point. So, my solution has been to create a Web Service that accepts SQL, and to put that Web Service in a VPN.
Rich
FreeTDS has a Darwin port, but I think is only for the OS X, not for iPhones.
Your (much) better option would be to go through the web service route.
I asked similar question on Serverfault.com, One of possibility is to set up SSH server on on your windows server and after that to telnnet in windows and use sqlcmd command prompt utility for MS SQL

Where can I find resources for setting up a Silverlight app that accesses sql server 2008 Express DB?

I am trying to set up a basic Silverlight application to run behind the firewall on my Windows XP machine with IIS 5.1. We have a MySQL server for production purposes, but I would like to set up SQL Server 2008 Express Edition on my Windows XP machine to host the database part of the application.
I'm completely new to a lot of .NET develoment but would like to find the resources to get started. I've checked out Silverlight.net/GetStarted/, but unless I missed something there, this step wasn't explicitly there.
Does anyone know where I could go to read about how to do this and maybe a simple walthrough of a sample Silverlight application written to access SQL Server 2008 Express?
Any suggestions and links would be much appreciated.
There are 3 options that I know of for connecting to a database from Silverlight:
WCF: Create your own WCF service with methods like GetCustomers(), UpdateCustomers() and DeleteCustomers(). Those methods are implemented on the server side, so in the background you can use LINQ to SQL or just open an old-fashioned SqlConection and run some SqlCommands against the database.
ADO.NET Data Services: This is a custom WCF service implemented by MS. You point the service at an Entity Framework class (auto generated from your custom database, super easy to create) and in turn it'll accept standard http rest commands that that do things like GetCustomers/Update/Delete. You can then add a service reference to this guy from your Silverlight app and it will auto generate 1 class per table, etc along with a client to connect to the server (http port 80 so no firewall concerns here). On the client side you're interacting with rich classes that look just like your database structure and work well with LINQ. This is not Silverlight specific and could be used from any client, even a console app.
.NET RIA Services: This is like ADO.NET Data Services but adds support for many things Silverlight including property change notification on the client side (note that the bleeding edge CTP2 of ADO.NET Data Services also implements change notifications), easy to hook events for browser navigation (i.e. you get an event when the user clicks back or forward) and code sharing between the server and the client (just name your file MyClass.shared.cs in your ASP.NET application and it magically shows up in your Silverlight client).
All of these options use http port 80 so they'll work well with your firewall. I'd really encourage you to try all 3 if you've got the time. If you don't have the time go directly to ADO.NET Data Services (grab the CTP2 you'll appreciate the new features).
Plain vanilla SL + WCF + SQL, but it's a little old:
http://msdn.microsoft.com/en-us/magazine/cc794260.aspx
Shawn Wildermuth's MSDN article is a good starting point for ADO.NET Data Services:
http://msdn.microsoft.com/en-us/magazine/dvdarchive/cc794279.aspx
This will get you up and running with good results in short time but note that it uses beta software. You'll see how many improvements have been made to ADO.NET DS since Shawn wrote that previous article:
http://blogs.msdn.com/astoriateam/archive/2009/09/01/introduction-to-data-binding-in-ctp2.aspx
And here's Brad Abram's mother of all data connectivity posts (RIA Services focus here - I think the series is up to 24 parts now):
http://blogs.msdn.com/brada/archive/2009/08/02/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-summary.aspx

Resources