常用思路:利用datatable來儲存資料,然後遍歷。如string strsql="select a from test" SqlConnection conHand = new SqlConnection(strConnection); SqlDataAdapter adaHand = new SqlDataAdapter(strSql, conHand); if (conHand.State == 0) conHand.Open(); DataSet setHand = new DataSet(); adaHand.Fill(setHand, "tables"); setHand.RemotingFormat = SerializationFormat.Binary; conHand.Close(); datatable tmpTable=setHand.Tables[0];foreach(datarow tmpRow in tmpTable.rows){ consoles.writeline(tmpRow["a"].toString());}
常用思路:利用datatable來儲存資料,然後遍歷。如string strsql="select a from test" SqlConnection conHand = new SqlConnection(strConnection); SqlDataAdapter adaHand = new SqlDataAdapter(strSql, conHand); if (conHand.State == 0) conHand.Open(); DataSet setHand = new DataSet(); adaHand.Fill(setHand, "tables"); setHand.RemotingFormat = SerializationFormat.Binary; conHand.Close(); datatable tmpTable=setHand.Tables[0];foreach(datarow tmpRow in tmpTable.rows){ consoles.writeline(tmpRow["a"].toString());}