C#应用程序数据库集成 [英] c# application database intergration

查看:108
本文介绍了C#应用程序数据库集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在设计一个可以从数据库中选择数据并将其放入文本文件的应用程序,有人知道吗,在c#中是否有可能进行某种用户控制,用户可以用来选择要尝试连接的数据库类型例如,使用口头SQL,SQL Express,Access,普适SQL,然后选择表,然后选择列,然后能够过滤数据以仅选择过滤后的数据,然后将其导出到文本文件.任何帮助将不胜感激

谢谢您的时间.

Hi all

I am designing an application that can select data from a database and put that data into a text file does anyone know if it is possible in c# to make some kind of user control that users can use to select the database type they are trying to connect to example orical sql, sql express , access, pervasive sql and then select the table and then select the columns and then be able to filter the data to select only the filtered data and then export that to a text file. any help would be appreciated

Thank you for your time

推荐答案

为了使您的应用程序可以使用多种数据库类型,您将必须在整个代码中使用接口和抽象类来进行数据库操作.您的代码应使用IDbConnection接口或DbConnection以及类似的类,而不是具体的类.

当然,这假设您将要使用的所有提供程序都实现或扩展了上述接口和类.

为了使您的应用程序松散耦合",您可以编写自己的代码,也可以使用网络上现有的现有框架之一. [ ^ ]页面显示了许多可以在此处使用的第三方易用容器.

我在这里可以看到的另一个障碍是查询语法.如果整个数据库中使用的查询语法之间存在巨大差异,我建议您在代码中实现自己的少量查询语法,然后根据用户选择的数据库对其进行解析.
In order to make your application work with multiple database types, you will have to use interfaces and abstract classes throughout the code for database operations. Your code should make use of IDbConnection interface or DbConnection and similar classes rather than concrete classes.

Of course, this assumes that all the providers that you are going to use implement or extend the aforementioned interfaces and classes.

In order to keep your application "Loosely coupled", you can either write your own code to do so or use one of the existing frameworks available on the web. This[^] page shows a lot of third party readily available containers that can e used here.

Another roadblock I can see here is the query syntax. If there is drastic difference between query syntax used across the database, I would suggest have your own little query syntax implemented in code and then parse it according to the database that user selects.


有一些第三方工具/库,可以帮助您开发独立的数据库应用程序.
看看企业库 [
There are some third party tools / libraries that can help you develop independent database applications.
Have a look at the Enterprise Library [^], for example.


这篇关于C#应用程序数据库集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆