日期:2014-05-17 浏览次数:20900 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class QQquery : System.Web.UI.Page
{
DataSet finaldata = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "over";
}
//数据集转字符串数组,用于遍历
public string[] ds2string(DataSet _ds)
{
int n = _ds.Tables[0].Rows.Count;
string[] s = new string[n];
for (int i = 0; i < n; i++)
{
s[i] = _ds.Tables[0].Rows[i][0].ToString();
}
return s;
}
//获取所有数据库的名字
public DataSet getAllDataBase()
{
SqlConnection coon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString);
string sqlstr = "select name from sys.databases where name like 'GroupData%'";
SqlDataAdapter da = new SqlDataAdapter(sqlstr, coon);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
//获取数据库下的所有表
public DataSet getTable(string _DataBaseName)
{
SqlConnection coon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString);
string sqlstr = "SELECT name FROM " + _DataBaseName + "..SysObjects Where XType='U' and name!='dtproperties'";
SqlDataAdapter da = new SqlDataAdapter(sqlstr, coon);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
//获取数据库中表的数据
public DataSet QueryData(string _DataBaseName, string _TableName, string _QueryNum)
{
SqlConnection coon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionS