Use silverlight to query mysql - c#

I have a silverlight application which reads data from a db and displays them in a grid.
As far as i understand it there are two ways to do it.
1) Read db with a server-side language, such as php, create a file in the server which you can later use in Silverlight to read the data.
2) Connect "directly" using Silverlight code with your db and do your job there. I have read some posts that explain more or less how this is possible, but i haven't found a working example.
I really need to go towards the 2nd approach. Can anyone provide a simple example on how to connect and query to your mysql db safely from Silverlight?
Thank you.

You could use the MySQL connector for Entity Framework and then connect to the database using .NET RIA Services.
Whatever route you go you're going to need to create some method to read data from the database on the server and return that to Silverlight as objects.

Silverlight runs on the client side in the browser, there is no way to directly hit a database. The way to get data is to hit a webservice, you could use ADO Data Services but they only run Sql Server in their cloud.

Related

How to send data from a Sql Server to another Sql Server (Not Linked) Using C# ASP.NET HttpClient

I need to send data from one Database (Server A) to another Database (Server B), on both server I have an ASP.NET application. I've searched about using a XML file with HttpClient Post. I don't want to use Web Service because i can't modify the Server B's application (I'll use an aspx file that already receive a xml from a Android App).
Any advice? If you can share some links about how can i do it i'll appreciate it :)
Thank you for your time, peace.
You don't have to use an XML for transferring data. You can use a C# ADO.Net or Entity Framework console or windows program or ASP.net website (with a button control) that will have the functionality to collect the data from one server and insert it in the other server.
Can't you generate a DataModel for Server B's backend using EntityFramework?
If you can connect to Server B's database, you can generate this from Visual Studio.
Once you have your Conceptual Model, you can use EntityFramework to add data to the other server.
e.g.
using(var db = new ServerBDatabaseContext())
{
db.databaseTable.Add(someObjectFromDatabaseA);
db.SaveChanges();
}
This video may help you accomplish what you're looking for
https://msdn.microsoft.com/en-us/data/ff191186.aspx
Hope this helps.

MS Access link to a Data Service (SQL Server) via WCF

Our client has an MS Access application which we want to link to a SQL Server database.
We want to write some sort of WCF service to provide the Access Database with the correct data from our SQL Server.
But where should I start with this?
And suppose I already have create the service.
Why can't I add any external services in my Access app?
It's greyed out and I haven't got a clue why.
Does anyone have experiences with this type of solution?
I don't think anyone does have experience as to do it in Access would be very difficult. You can create Linked tables in access, which look just like Access Tables, but are actually linked to a table in a SQL Server db, but that's not what you want. There is no 'natural' way to link a table to a WCF Service.
However, it might be possible, with an enormous amount of work, that you could call the WCF service and unserialise the returned XML data via VBA code within the Access application. I would not personally attempt it, and would discourage all but my worst enemies from doing so.
Why can't I add any external services in my Access app? It's greyed out and I haven't got a clue why.
The "Data Services" option is only available from within .accdb files. It is greyed out if an .mdb file is open.

Connecting MySQL Proxy to a C# Application

I'm currently working on a project that involves splitting large MySQL databases into multiple smaller shards. However, clients must be able to query the databases just as they had before with no change to the user interface; that is, any query they send through a MySQL client (Workbench, DBForge, etc) must return the same result set from the master database as it does from its shards.
This requires that an application be seated between the client and server to intercept queries, analyze them, modify them, and redirect them to master databases or shards as need be. I know that MySQL Proxy is particularly suited to this task, but that's where the problem comes in.
I've already written a C# application that takes a MySQL query string, modifies it, queries whichever shards it must, and aggregates the results from all shards. My problem is that I don't know how to connect MySQL Proxy to this application. Ideally, MySQL Proxy would intercept a query, determine whether it is "shardable" or not, and send it either to my sharding application or to the master database. The sharding application would then send its result set back to MySQL Proxy, which would return it to the client.
Is there any clear way to accomplish this? Perhaps if I were to turn the C# application into a WCF service? MySQL Proxy has methods for connecting to databases, but I don't know if it can connect to a simple web service, much less a WCF, considering it's written in Lua. Is there some alternative to MySQL Proxy that would better meet my needs?
Mysql allows you to script with Lua and connect to C or C++. I have no experience in C# but I supose you will have no problem.
Install mysql-proxy. You can determine one or more backend mysql DB.
Compile your C code as a module to be called from Lua: link
Depending on your code set the backend IP for your query and redirect it.
Be carefull when searching Lua documentation, because mysql-proxy implements Lua 5.1, and procedures change quite a bit from version to version.

connecting to oracle database from c# asp.net mvc website

I am trying to connect to oracle database. I am able to connect to it through a local SQL Developer tool by sticking something in the oranames.tns file.
My question is that i will be deploying this website to a number of places. A few questions:
What is the simplest way i can use to connect to this database and do very basic queries. I see some examples that have me referencing oracleclient dlls. Other methods not? Is there a best practice here?
Am i going to have to update the oranames.tns file on everyone on of the machines that i deploy to ? is there any simpler way
1.
You can use the Oracle data provider that comes with Microsoft, but I recommend using ODP.Net. It's best to use native libraries when possible since they are usually optimized better, at least in my experience.
2.
You only need to configure the tnsnames.ora on the server, because the server is what's going to be handling the DB connections, not the client PCs (assuming that this is a MVC website).

Best way to synchronise client database with server database

I have a datalogging application (c#/.net) that logs data to a SQLite database. This database is written to constantly while the application is running. It is also possible for the database to be archived and a new database created once the size of the SQLite database reaches a predefined size.
I'm writing a web application for reporting on the data. My web setup is c#/.Net with a SQL Server. Clients will be able to see their own data gathered online from their instance of my application.
For test purposes, to upload the data to test with I've written a rough and dirty application which basically reads from the SQLite DB and then injects the data into the SQL Server using SQL - I run the application once to populate the SQL Server DB online.
My application is written in c# and is modular so I could add a process that periodically checks the SQLite DB then transfer new data in batches to my SQL Server.
My question is, if I wanted to continually synchronise the client side SQLLite database (s) with my server as the application is datalogging what would the best way of going about this be?
Is there any technology/strategy I should be looking into employing here? Any recommended techniques?
Several options come to mind. You can add a timestamp to each table that you want to copy from and then select rows written after the last update. This is fast and will work if you archive the database and start with an empty one.
You can also journal your updates for each table into an XML string that describes the changes and store that into a new table that is treated as a queue.
You could take a look at the Sync Framework. How complex is the schema that you're looking to sync up & is it only one-way or does data need to come back down?
As a simply solution I'd look at exporting data in some delimited format and then using bcp/BULK INSERT to pull it in to your central server.
Might want to investigate concept of Log Shipping
There exists a open source project on Github also available on Nuget. It is called SyncWinR, it implements the Sync Framework Toolkit to enabled synchronization with WinRT or Windows Phone 8 and SQLite.
You can access the project from https://github.com/Mimetis/SyncWinRT.

Categories

Resources