ADO.NET 多個Command查詢的方法
////using (SqlConnection conn = new SqlConnection(strConnString)) {
//// conn.Open();
//// using (SqlCommand cmd = new SqlCommand()) {
//// cmd.Connection = conn;
//// // 利用分號「;」串接多個sql語法,再透過NextResult()再執行第二個sql語法
//// cmd.CommandText = "SELECT T1,T2 FROM TABLE1 ; SELECT T1,T2 FROM TABLE2";
//// using (SqlDataReader dr = cmd.ExecuteReader()) {
//// while(dr.Read()) {
//// this.DropDownList1.Items.Add(dr.GetSqlString(0).ToString() + dr.GetSqlInt32(1).ToString());
//// }
//// dr.NextResult();
//// while(dr.Read()) {
//// this.DropDownList2.Items.Add(dr.GetString(0) + dr.GetInt32(1));
//// }
//// }
//// }
////}
沒有留言:
張貼留言