惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
P
Palo Alto Networks Blog
C
Cisco Blogs
The Hacker News
The Hacker News
T
Threatpost
S
Schneier on Security
K
Kaspersky official blog
Spread Privacy
Spread Privacy
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
NISL@THU
NISL@THU
量子位
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google DeepMind News
Google DeepMind News
Security Latest
Security Latest
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
博客园 - 叶小钗
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
News and Events Feed by Topic
爱范儿
爱范儿
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Project Zero
Project Zero
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cisco Talos Blog
Cisco Talos Blog
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
T
Tenable Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Vulnerabilities – Threatpost
Forbes - Security
Forbes - Security
博客园 - 三生石上(FineUI控件)
C
Cyber Attacks, Cyber Crime and Cyber Security
N
News and Events Feed by Topic
V
V2EX
Webroot Blog
Webroot Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Blog — PlanetScale
Blog — PlanetScale
M
MIT News - Artificial intelligence
Scott Helme
Scott Helme
Simon Willison's Weblog
Simon Willison's Weblog
L
LangChain Blog
W
WeLiveSecurity
Cloudbric
Cloudbric

博客园 - rapid

Rapid Business Development: Lightswitch vs. Dynamics CRM vs. SharePoint 2010 vs. ASP.NET MVC 3 OCS 2007 R2下载资源整理 下载silverlight官网的全部视频 [已修正链接] 对Scott Gu的Silverlight Sample--DiggSample的修改 - rapid 让Windows7顺利识别笔记本4G内存 “最郁闷的一次面试经历”勾起我对面试经验的一些看法 OpenSesame示例源码 转:WF中的跟踪服务(1):Sql跟踪数据库表,视图,存储过程等相关说明 转:技巧:使用User Control做HTML生成 转:一点一点学ASP.NET之基础概念——HttpModule Increasing the CRM 4.0 Attachment Size Limit 超级实用且不花哨的js代码大全 (转)编写发布Plug-In 转:汉字转全拼,简拼组件 转:高阶函数、委托与匿名方法 转:.NET平台下Web测试工具横向比较 比较著名的.net技术论坛网址(含国外的) SMO学习笔记(一)——备份篇之完全备份 网站管理模板 stp 安装解决办法
转:数据库管理对象(SMO)-为什么没有System.Data.DBManagement命名空间?
rapid · 2009-03-31 · via 博客园 - rapid

     最近要为我们的程序增加数据导出的功能,需用连接数据库,再列出数据库中的表。功能并不复杂,实现也没有难度。而且VS本身就自带了这个东东。如图:

     我所奇怪的是,既然微软已经做了这个工作。为什么没有给出现成的类库给我们使用呢?我觉得非常明显的,应该有一个System.Data.DBManagement命名空间,用于开发者开发出自己的数据库管理程序。如果仅仅因为不同的数据库不一样。那么可以分别有System.Data.DBManagement.Sql,System.Data.DBManagement.Oracle等等。按照我的设想大致应该有如下类:


      假如我们要获得某个数据库的所有表,我们就可以写以下代码:


        Server myServer=new Server();
        myServer.Name
="localhost"
;
        myServer.TrustConnection
=true
;
        Database db
=new
 Database();
        Database.Server
=
myServer;
        TableCollection tables
=Database.GetTables();

      以上的示例只是简单的意思一下。如果要覆盖所有数据库管理工具的功能,应该是一个比较庞大的类库了。我不知道哪里是不是已经有这样的类库,如果没有,只有自己开发了...

      帖子发表以后,根据很多朋友的指点(多谢下面的各位同学,具体就不点名了)。一共有三个答案。

      1.Sql Server的SDK中的SQL Server Management Objects (SMO)应该就是本案的标准答案。美中不足的是,微软只提供Sql Server的数据库管理对象的类库,不支持其他数据库。

      这是MSDN上SMO(SQL Server2005)的地址http://msdn.microsoft.com/zh-cn/library/ms162169(SQL.90).aspx

      另外一篇介绍SMO的文章http://hi.baidu.com/qualylee/blog/item/0e4e0e33a64127fb1a4cff53.html

      2.MyGeneration的MyMeta.dll中。功能肯定不如SMO强,但是提供了对数据库管理的比较丰富的类,并且支持十几种数据库。尤其可喜的是,MyGeneration现在是开源的。http://sourceforge.net/projects/mygeneration/

      不过毕竟MyMeta.dll 的目的并不是用于管理数据库,因此可能对于管理数据库方面的功能少了点。

      3.SQL Server Web Data Administrator 的SqlAdmin.dll。SQLWebAdm 是在CodeComplex的一个开源项目,也是微软团队开发的,因此也只支持Sql Server。该项目主要是SQL Server管理器的Web版本(不过好像很久没有更新了最近更新时间2007年11月),但是它并没有引用SMO的类库而是自己开发了SqlAdmin.dll,也许是为了独立吧。SqlAdmin.dll中的类跟MyMeta.dll中MyMeta.Sql命名空间的类有些类似,可谓英雄所见略同吧。

      http://www.codeplex.com/SqlWebAdmin

       补充:实用ADO.NET的DbConnection 类的 GetSchema 方法也可以获取数据库的架构信息。

       http://msdn.microsoft.com/zh-cn/library/kcax58fh(VS.80).aspx

      我们的项目需要自动生成导入数据的脚本,假如目标数据库中已经存在数据,对于自增列值冲突的问题要有特殊的解决,等我研究好了我会在下篇随笔中公布源代码和详细描述,假如哪位朋友已经有现成的解决方案,也希望不吝赐教。