We want to allow access to our custom back end data store by pretending to be an ODBC server such as Access or SQL Server. In this way, anyone with those ODBC drivers could connect and send us queries (from anything from asp.net to Excel) which we will resolve on the back end and return a result set.
I have the ability to parse SQL and return result set based on a dynamic sql query. What I don't know is how to pretend to be an ODBC or OLEDB server. I don't even care which server we mimic as long as it's a common one that has drivers that ship with windows.
I have searched but could not find a basic implementation that implements authentication and ExecuteQuery() methods. Does such a .net project exist?
You could implement an ADO.NET data provider?
see http://msdn.microsoft.com/en-us/library/a6cd7c08.aspx
The System.Data.Sqlite project is an excellent example of how to build an ADO.NET data provider for an arbitrary data store.
Related
I'm writing a C# application that needs to be able to query and update an Azure SQL database. I've looked into ADO.NET, which appears to be a great library for querying SQL databases without just writing the queries as string literals.
Before I invest too much time into learning this library I want to make sure that I can connect it to Azure successfully. I found this article which appears to have at one point contained a tutorial for doing exactly that, but doesn't exist anymore. Can anyone confirm that ADO.NET can be used with Azure SQL?
Yes, Of course we can.
ADO.NET can be used with Azure SQL, we can use ADO.NET to operate Azure SQL just like we operate SQL Server. But there are some differences between Azure SQL Db and SQL Server, we can refer to: Feature comparison: Azure SQL Database versus SQL Server
We can also use Linq to SQL to operate SQL Azure for some simple operations because it is more convenient to operate our database. More information we can refer to: LINQ to SQL: .NET Language-Integrated Query for Relational Data
You can and you can find the connection string to use in the Azure Portal. Here's a guide:
https://learn.microsoft.com/en-us/azure/sql-database/sql-database-connect-query-dotnet-visual-studio
Good morning all,
recently I came upon problem with DB connection in Python and C#.
For example, let's say we want to connect SQL Server. In .NET (C#) we just need to know the server name, credentials and we can connect to DB with SqlConnection object. That's clear.
Now, in Python, when using pypyodbc we need to specify driver additionally. And here's come the question:
Why in Python we have to specify driver? We don't have to specify it in C#.
On the other hand, if specifying driver is so crucial, then why don't we have to specify it in C#?
I know, that in C# we have dedicated class for SQL Server (does Python? or pypyodbc is the only choice?), does that mean, that it has some method to resolve which driver to use? Is it the same with Oracle?
I know nothing about python, but I think that should answer your main question:
SqlConnection is designed specifically to work with SQL server, so you don't need to specify the driver, because it uses it's own designated driver.
From SqlConnection.ConnectionString Property page on Microsoft docs:
The ConnectionString is similar to an OLE DB connection string, but is not identical. Unlike OLE DB or ADO, the connection string that is returned is the same as the user-set ConnectionString, minus security information if the Persist Security Info value is set to false (default). The .NET Framework Data Provider for SQL Server does not persist or return the password in a connection string unless you set Persist Security Info to true.
(Emphasis mine, other stuff in the quot are just to provide context.)
And later on down the page:
The .NET Framework Data Provider for SQL Server uses its own protocol to communicate with SQL Server. Therefore, it does not support the use of an ODBC data source name (DSN) when connecting to SQL Server because it does not add an ODBC layer.
(again, emphasis mine.)
When working with other connection classes such as OdbcConnection or OleDbConnection, you need to specify the driver in the connection string.
With Odbc Connection Strings use the keyword Driver,
and with OleDb Connection Strings use the keyword Provider.
About Oracle, The .Net framework have a namespace called System.Data.OracleClient, but it's deprecated (from Oracle and ADO.NET):
The types in System.Data.OracleClient are deprecated. The types remain supported in the current version of.NET Framework but will be removed in a future release. Microsoft recommends that you use a third-party Oracle provider.
I'm guessing Oracle's own ADO.Net implementation also works with it's own driver. If you really want to know, you can look it up in their documentation.
I need your help to answer a question.
I coded a basic c# portable exe application that uses an Access Database on a server computer. On the network there are some client computers that runs this application and retrieve and store data via this database placed on the server computer in a shared folder. Every client coputer can access my database with this connection string:
#"Provider=Microsoft.ACE.OLEDB.12.0;Data Source =\\ANKFILESERVER1\aractakip\DatabaseAd.accdb
So far, there has been no problem. But as known, Access (Oledb) database has a limited capacity to save datas and since i'm worrying that someone change or delete my database files -authenticated for everyone- i decieded to use another database platform like postgresql.
My question is, if i install postgresql on the server computer and migrate my database tables, Are every client computers needed to install postgresql to access my database tables? If yes, what should be my connection string?
Thanks in advance.
You will need a client driver - like psqlODBC - installed on each computer that connects to PostgreSQL via MS Access, yes.
You can install psqlODBC separately, or using the main PostgreSQL installer. The separate psqlODBC-only installer is an msi that can be deployed over Active Directory, making management easier.
The connection options are covered in the psqlODBC documentation.
Microsoft Access is really written for the Microsoft JET / OLEDB engine, and to communicate with Microsoft SQL Server. It works with PostgreSQL, but it doesn't fully "understand" all PostgreSQL's features. It also does some things in totally non-SQL-standard ways that work on MS SQL but do not work on PostgreSQL. So it can be awkward to use MS Access with PostgreSQL due to things like Access not really supporting SEQUENCEs properly. Note, though, that I haven't used Access since Office 2008, so things may have improved.
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.
I have a web based CRM system that stores all the client data from all the clients into one database (MS Sql Server). We need to build a system that maintains a local copy of the data for each client. So basically the client database will have all tables and columns except for the ClientId that is in ever server table. I am aware that I will need to add fields to the server to support synchronization.
Are there any good solutions or components already out there to help me accomplish this?
We are using MS Sql Server and .NET C#
SQL Server vs. a local one (express) - this is what MS does in it's CRM.
Sync framework (part of SQL Server etc.) could be helpful to programming a sync mechanism, in case you do not want to use replication here - which MAY work.