views:

52

answers:

3

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.

+3  A: 

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.

Justin Niessner
+1  A: 

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.

Joel Coehoorn
I guess what I can't get my head wrapped around (new to Siverlight)...Once I have the connection string built server-side where/how do I use the connection string in code, whether it be in a web service or in Silverlight to open an actual SqlConnection object that I could then use to perform queries?
Dave Jellison
Not in silverlight: you have to submit back to a web server (probably running plain asp.net) and do the work there.
Joel Coehoorn
Which would require the SQL server to allow a remote connection correct? If that is the case the above comment would be valid, this isn't a Silverlight question. I was hoping to subvert a remote connection via. Silverlight but I may be barking up the wrong tree is seems. I'm at a loss for how, even with credentials, using a web service you could access a local SQL connection as the code would need to run on the client. That was the leap I was hoping to make if that makes sense.
Dave Jellison
Ah: I see I missed something. You're looking for the local instance on the developer's machine, not a database on the web server. Silverlight won't let you connect to that directly. The gist of my answer still stands: Silverlight won't let you connect directly. But you might be able to get it working through a proxy of some kind.
Joel Coehoorn
That was my next thought. Sorry I wasn't very clear. My only thought is a browser plugin or something of that nature but I was hoping to avoid that. Thank you for your quick responses! (all of you)
Dave Jellison
you could maybe do a little clickonce winforms app as your proxy. That looks almost like a web page.
Joel Coehoorn
Since you made this the accepted answer I'm gonna edit to promote the results of the comments to the answer itself...
Joel Coehoorn
Yep. Thanks again Joel
Dave Jellison
A: 

With silverlight you cannot access the local machine/network resources. you will need to use wpf/xbap.

Aaron Fischer
I did look at xbap briefly but the security model at first glance looked prohibitive.
Dave Jellison
I did look at xbap briefly but the security model at first glance looked prohibitive.
Dave Jellison
Please excuse the double post
Dave Jellison
@Dave: just delete one of your duplicate comments ;-)
marc_s