/// <summary>
/// 返回所有表
/// </summary>
/// <returns></returns>
public static DataTable GetAllTables()
{
DataTable dt = new DataTable(); try
{
Con.Open();
dt = Con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,new object[]{null,null,null,"Table"});
}
catch(Exception ex)
{
throw ex;
}
finally
{
Con.Close();
} return dt;
} /// <summary>
/// 返回指定表的结构
/// </summary>
/// <param name="varTableName"></param>
/// <returns></returns>
public static DataTable GetTheTable(string varTableName)
{
DataTable dt = new DataTable(); DataSet ds = new DataSet(); OleDbDataAdapter Odb = new OleDbDataAdapter("select * from " + varTableName,Con);
try
{
Con.Open();
Odb.FillSchema(ds,SchemaType.Source,varTableName);
}
catch(Exception ex)
{
throw ex;
}
finally
{
Con.Close();
}
return ds.Tables[varTableName];
}

解决方案 »

  1.   

    DataSet ds = new DataSet();
    SqlConnection conn = new SqlConnection(dbConnectionString);
    SqlCommand comm = new SqlCommand("sp_columns",conn);
    comm.CommandType = CommandType.StoredProcedure;
    //tblName:要查看的表名
    comm.Parameters.Add("@table_name",SqlDbType.NVarChar).Value = tblName;
    SqlDataAdapter dap = new SqlDataAdapter(comm);
    dap.Fill(ds,"columnInfo");
    DataTable dt = ds.Tables["columnInfo"];
    //在dt中查看这些信息就可以了
      

  2.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=ZP4KXO6X-I697-4I4R-YKYB-6KFVPBC5JJPU
      

  3.   

    到SQL论坛找一下吧。有这方面的资料。
    我在办公室有一个这样的存储过程。
    可惜这台微机没有 数据库。