获取SqlDataReader的列名
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取SqlDataReader的列名相关的知识,希望对你有一定的参考价值。
SqlConnection thisConnection = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"].ToString()); // Open connection thisConnection.Open(); // Create command for this connection SqlCommand thisCommand = thisConnection.CreateCommand(); // Specify SQL query for this command thisCommand.CommandText = sCommandText; // Execute DataReader for specified command SqlDataReader thisReader = thisCommand.ExecuteReader(); // While there are rows to read // // View_LogDetailEntity = new List<CView_LogDetail>();//初始化集合 string sColumnName = string.Empty; while (thisReader.Read()) { CView_LogDetail myCView_LogDetail = new CView_LogDetail(); for (int i = 0; i < thisReader.FieldCount; i++) { sColumnName = thisReader.GetName(i).Trim(); } }
以上是关于获取SqlDataReader的列名的主要内容,如果未能解决你的问题,请参考以下文章