如何从不同的数据源中提取数据SQL,mysql和MS访问 [英] How to pull data from different data sources SQL, mysql and MS access

查看:152
本文介绍了如何从不同的数据源中提取数据SQL,mysql和MS访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,我必须从不同的数据源提取数据。我有3个数据源 SQL服务器 MySQL MS Access 。要求是我需要在我的应用程序(主SQL服务器2016数据库)中定义表名和列名,并根据这些定义,我的系统需要连接到这些数据源,然后从指定的表中提取数据并插入到我的主要SQL数据库。此数据提取活动将按预定时间运行。现在我正在考虑开发一个Windows服务,它将连接到数据源,然后将数据转储到我的主SQL数据库。 还有其他好办法吗?



我尝试过:



在网上搜索但找不到答案

解决方案

在ado.net中使用Oleb数据对象,如System.Data .OleDb.OleDbConnection,OleDbCommand等。这将允许您为每个数据库提供特定于数据库的连接字符串,并使用相同的代码和sql来查询它们,只需要更改连接字符串。



Google for OleDbConnection代码示例,如果您之前从未使用过ado.net。


为了实现这一点,您必须编写/创建通用数据访问方法。

请点击以下链接:

编写便携式数据访问层 [ ^ ]

通过ADO.NET接口简化数据库访问 [ ^

I have a requirement where I have to pull data from different data sources. I have 3 data sources SQL server ,MySQL and MS Access. The requirement is that I need to define that table name and columns name in my application (main SQL server 2016 database) and based on these definition my system need to connect to these data sources and then pull the data from the specified tables and insert to my main SQL database.This data pulling activity will be working as per the scheduled time. Right now I am considering to develop a windows service which will connect to the data sources and then dump the data to my main SQL database. Is there any other good way to do this?

What I have tried:

Searched on net but could not find the answer

解决方案

Use the Oleb data objects in ado.net like System.Data.OleDb.OleDbConnection, OleDbCommand and so on. That will let you supply a database-specific connection string for each of your databases and use the same code and sql to query against them, needing to change only the connection string.

Google for OleDbConnection code samples if you've never used ado.net before.


To be able to achieve that, you have to write/create Universal Data Access Approach.
Follow these links:
Writing a Portable Data Access Layer[^]
Simplified Database Access via ADO.NET Interfaces[^]


这篇关于如何从不同的数据源中提取数据SQL,mysql和MS访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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