//
定义必要的变量
private SqlConnection sqlConn;
private SqlDataAdapter sqlDA1;
private SqlDataAdapter sqlDA2;
private SqlCommand sqlComm;
private System.Data.SqlClient.SqlDataReader dr;
// 初始化变量
sqlConn.ConnectionString = " 字符串 "
sqlConn.Open();
sqlComm.CommandText = " select * from 表名 " ;
sqlComm.CommandType = CommandType.Text;
sqlComm.Connection = sqlConn;
dr = sqlComm1.ExecuteReader();
// 取字段
string s;
for ( int i = 0 ;i <= dr.FieldCount - 1 ;i ++ )
{
s+=dr.GetName(i);//此方法返回字段名;
}
private SqlConnection sqlConn;
private SqlDataAdapter sqlDA1;
private SqlDataAdapter sqlDA2;
private SqlCommand sqlComm;
private System.Data.SqlClient.SqlDataReader dr;
// 初始化变量
sqlConn.ConnectionString = " 字符串 "
sqlConn.Open();
sqlComm.CommandText = " select * from 表名 " ;
sqlComm.CommandType = CommandType.Text;
sqlComm.Connection = sqlConn;
dr = sqlComm1.ExecuteReader();
// 取字段
string s;
for ( int i = 0 ;i <= dr.FieldCount - 1 ;i ++ )
{
s+=dr.GetName(i);//此方法返回字段名;
}