日期:2014-05-16 浏览次数:20986 次
public List<string> title(string tableName)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.;Initial Catalog=Apriori;Integrated Security=True";
con.Open();
SqlDataAdapter ad = new SqlDataAdapter();
string sql = "select name from syscolumns where id=object_id('"+tableName+"')";
SqlCommand com = new SqlCommand(sql, con);
ad.SelectCommand = com;
DataSet ds = new DataSet();
ad.Fill(ds);
/*不知道怎么写了想返回字段名的数组*/
return names;
}
var names = new List<string>();
foreach (DataRow row in ds.Tables[0].Rows)
{
names.Add(row[0].ToString());
}
return names;