本文介绍了使用C#将数据库表结构导出到excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

大家好,我想使用c#将数据库表结构导出到excel中
3 ..

hello everybody i want to export database table structure to excel using c# in
3 tier architecture in asp.net and sqlserver 2008 database in 3....

推荐答案

using System.Data.SqlClient;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;


 SqlConnection conSql = new SqlConnection(ConnectionString);
            ServerConnection con = new ServerConnection(conSql);
            Server server = new Server(con);
            DatabaseCollection dbCollection = server.Databases;
            TableCollection tbls = dbCollection["YOURDBNAME"].Tables;
            System.Collections.Specialized.StringCollection sCollection = tbls["YOURTABLENAME"].Script();
            StringBuilder sb = new StringBuilder();
            string[] tblscriptArray = new string[tbls["YOURTABLENAME"].Script().Count];
            sCollection.CopyTo(tblscriptArray, 0);


这篇关于使用C#将数据库表结构导出到excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 18:19