cannot build silverlight library, what references do I need? - c#

I am converting a normal CLR library over to a silverlight library.
SqlConnection, SqlCommand, SqlClient aren't recognized. What libraries do I reference? I am working in Silverlight 3.0.

SqlConnection, SqlCommand, SqlClient are from system.data. System.Data is not part of the Silverlight.
For all database related activities, you should either use a webservice/wcf service/ria services/entity data framework for all crud operations.

As far as I can tell, it is not possible to directly access SqlServer from Silverlight. This makes sense since Silverlight is designed to create "web applications", implying that you'll need to use client-server methods to access the data. You could set up a WebMethod or WCF on a web server somewhere and point Silverlight at it to get the data.
References:
http://silverlight.net/learn/tutorials/sqldatagrid-cs/
http://forums.silverlight.net/forums/t/21012.aspx
http://www.codeproject.com/KB/silverlight/CntDbSlght.aspx

Related

Xamarin forms and sql server Database

I was working on UWP project in visual studio #xamarin forms, how do i connect to sql Database without using any Web API's and dependency services ?
The application is working in offline mode.
First of all, you must decide whether you want to use Microsoft SQL Server or Sqlite.
These are completely different databases and therefore the code will be different as well.
If you want to use MS SQL, you can use this article.
Somehow from your questions I think that Sqlite will serve you better (just my guess).
If you want to use Sqlite, check this one.
This recipe is designed for Xamarin.Forms PCL project and therefore uses dependency service - since the approach is different on iOS, Android and UWP. If you do not plan to port your project to Android or iOS, you can just call the functions directly, without dependcy service interface.

Accessing A MySQL Database In Silverlight (C#)

I am trying to access a MySQL database in a Silverlight application. I have tried to reference to System.Data.Services to access the SQLClient class, but it says:
You can't add a reference to
System.Data.Services.dll as it was not
built against the Silverlight runtime.
Silverlight projects will only work
with Silverlight assemblies.
I have also tried to add a reference to MySQL.Data, but received the same error.
I have read online that I will need to use a WebService, but I do not know how to make one.
I am using Visual Studio Ultimate 2010, I am targeting PHP and MySQL servers, not ASP, and would appreciate any help.
Alem, Silverlight is a client-side technology.
It will only work in browsers. You cannot just make direct call to a database from your Silverlight app.
First off, this would be a major security issue you don't want to deal so fortunately you are not even allowed to.
Use webservices, or even better: WCF services.
Try this link: http://chakkaradeep.wordpress.com/2008/05/31/silverlight-and-wcf/
Hope this helps.
you can access sql through php:
http://www.silverlightshow.net/news/PHP-MySQL-and-Silverlight-The-Complete-Tutorial.aspx

Shared WCF client code between .NET and Silverlight apps?

I'm developing a .NET application that will have both a WinForms and a Silverlight client. Although the majority of code will be in the server, I'll need to have quite a bit of logic in the clients as well, and I would like to keep the client library code the same.
From what I could figure out so far, I need to have two different project types, a class library and a Silverlight class library, and link the files from one project to the other. This seems kind of lame, but it works for simple code.
My problem, though, is that the code generated by the SVCUtil.exe to access WCF services is different from the code generated by the slsvcutil.exe, and the silverlight code is actually incompatible with the .NET one: I get a bunch of problems with the System.ServiceModel.Channel classes when I try to import the class into .NET.
Has anybody done anything similar to this before? What am I doing wrong?
Unfortunately, as of Silverlight 3 and .NET 3.5sp1, there is no binary compatibility. You must share files, and maintain two separate libraries.
Silverlight 4 and .NET 4, however, will provide some level of binary compatibility. Depending on which assemblies you use in your client side, you may be able to use the same component in both Silverlight and Windows Forms.
I know it's too late to provide a solution but it was my problem too and I found Portable Class Libraries. It's a perfect solution to your issue.
Don't try and share a single proxy client amongst disparate clients - generate a proxy per client.
You can reuse the data classes between the projects using the add as link method you described. If a new version of the classes is created in the proxy, then you can just edit the generated proxy code files and delete out the class definitions. When you compile this up each client (Windows app and silverlight) will have its own version of the compiled class library, but it is all coming from the same source code.

Can you use a C# library in a AMP-server?

Is it possible for me to build some database functionality in a C#-library (using LINQ 2 SQL) and then somehow import it into a php (joomla) project?
One way to do it is to register the .NET assembly as COM object (using regasm.exe) and then consume it from PHP.

SQLite3 in C#.NET

I'm trying to use SQLite3 in C#.NET. I've googled around and found some different API's. I also checked SQLite's website for wrappers. I like them, but want to write my own wrapper without using an added dependency. All wrappers I find that don't require an added dependency aren't free.
I'm wondering how one would read from, execute, and write to a sqlite3 database. Is it a socket connection(tcp? udp? etc?)? I've tried searching this answer on google and all I get are library-specific answers. :/ SQLite's website docs aren't much help either.
EDIT: I also found a COM interface while googling, but is that library specific?
Thanks SO! :)
Have you looked at the System.Data.SQLite library? It's a free ADO.NET library to interact with SQLite and requires nothing else in order to run, since it has the engine built into it.
I've been using it for a while now and find it really easy to work with. It even has a plugin for Visual Studio should you decide to use some strongly-typed tables with it or want to use it to add/create tables.
(Answering the "socket connection" question.)
Part of the point of SQLite is that it's an embedded database - there's no server to talk to, you load the library directly into your process and it talks to the file system directly.
If you want to use SQLite in .NET, you should take a look at System.Data.SQLite, which is a ADO.NET provider for SQLite
System.Data.SQLite is comparatively slower than other providers like SqlClient. I have look into its code.
Now I want to call it throw P/Invoke but not like SQLite provider. It call through P/Invoke every time when ever you access column value through DataReader

Categories

Resources