c#如何获取表的每一个字段名并并放到一个地方
strings="";SqlDataReaderdr;SqlConnectionsqlCon=newSqlConnection();sqlCon.ConnectionSt...
string s="";
SqlDataReader dr;
SqlConnection sqlCon = new SqlConnection();
sqlCon.ConnectionString = @"Data Source=.;Initial Catalog=qiyun3d;Integrated Security=True";
sqlCon.Open();
SqlCommand sqlCmd = new SqlCommand("select * from '" + str + "'", sqlCon);
dr = sqlCmd.ExecuteReader();
for(int i=0;i<=dr.FieldCount-1;i++)
{
s+=dr.GetName(i);
}
我是这样写的,但我想把他放到一个数组(或别的容器中),以便再用一个for来判断分别取得了那些字段名,该怎么做; 展开
SqlDataReader dr;
SqlConnection sqlCon = new SqlConnection();
sqlCon.ConnectionString = @"Data Source=.;Initial Catalog=qiyun3d;Integrated Security=True";
sqlCon.Open();
SqlCommand sqlCmd = new SqlCommand("select * from '" + str + "'", sqlCon);
dr = sqlCmd.ExecuteReader();
for(int i=0;i<=dr.FieldCount-1;i++)
{
s+=dr.GetName(i);
}
我是这样写的,但我想把他放到一个数组(或别的容器中),以便再用一个for来判断分别取得了那些字段名,该怎么做; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询