ExecuteScalar 要求已打开且可用的连接。连接的当前状态为已关闭
问题是:我已经在每次用完DataReader后,都把对应的DataReader关闭了,同时他们共用一个SqlConnection,不过我每次用时,都把CommandText改过来了,可是还是出现这个错误提示,请高手指点。
this.Exsql.Open();
string cmdText = " ";
string text2 = " ";
string text3 = " ";
string text4 = " ";
string text5 = " ";
cmdText = "select DISTINCT YX_ProID from YX_Shoping ";
SqlCommand com = new SqlCommand(cmdText, this.Exsql.con);
SqlDataReader reader = com.ExecuteReader();
DataSet set = new DataSet();
DataTable table = new DataTable( "tab1 ");
set.Tables.Add(table);
DataColumn column = new DataColumn( "YX_ID ", Type.GetType( "System.Int32 "));
set.Tables[ "tab1 "].Columns.Add(column);
column = new DataColumn( "YX_ProName ", Type.GetType( "System.String "));
set.Tables[ "tab1 "].Columns.Add(column);
column = new DataColumn( "YX_ProNum ", Type.GetType( "System.Int32 "));
column.DefaultValue = 0;
set.Tables[ "tab1 "].Columns.Add(column);
column = new DataColumn( "YX_ProPic ", Type.GetType( "System.String "));
set.Tables[ "tab1 "].Columns.Add(column);
int Lenreader = -1;
Hashtable hashtable = new Hashtable();