DBConnection2.Open()
SQLString ="SELECT * FROM details where product_id =" & product_id
Dim DA AS New SqlDataAdapter(SQLString, DBConnection2)
Dim DS AS New DataSet()
DA.Fill(DS, "ProductDetail")
Dim DR As DataRow()
countprod.item.clear()
Foreach DR in DS.Table("ProductDetail")
Countprod.item.add(DR("details_p1").tostring)
EndFor
Foreach DR in DS.Table("ProductDetail")
Countprod.item.add(DR("details_p3").tostring)
EndFor
Foreach DR in DS.Table("ProductDetail")
Countprod.item.add(DR("details_p5").tostring)
EndFor
Foreach DR in DS.Table("ProductDetail")
Countprod.item.add(DR("details_p7").tostring)
EndFor
ถ้ายากไปแนะนำอีกวิธีหนึ่งครับ
DBConnection2.Open()
SQLString = " SELECT details_p1 FROM details UNION ALL "
SQLString &= " SELECT details_p3 FROM details UNION ALL "
SQLString &= " SELECT details_p5 FROM details UNION ALL "
SQLString &= " SELECT details_p7 FROM details "
SQLString &= " WHERE product_id =" & product_id "
DBCommand2 = New sqlCommand(SQLString, DBConnection2)
DBReader2 = DBCommand2.ExecuteReader()
While DBreader2.Read()
countprod.DataSource= DBReader2("details_p1")
End While
countprod.DataBind()
DBReader2.Close()
DBConnection2.Close()