 |
|
Code ผมประมานี้ คับ
Code (VB.NET)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strConn As String
Dim sqluername As String
strConn = WebConfigurationManager.ConnectionStrings("conn").ConnectionString
Dim Conn As New SqlConnection(strConn)
Conn.Open()
sqluername = "SELECT name_drug, mode, sum(quantity) As total_quantity FROM drug, mode WHERE drug.id_mode = mode.id_mode GROUP BY name_drug HAVING sum(quantity) <= 2 order by total_quantity "
Dim da As New SqlDataAdapter(sqluername, Conn)
Dim ds As New DataSet
da.Fill(ds, "drug")
GridView1.DataSource = ds.Tables("drug")
GridView1.DataBind()
End Sub
เป็นการ Select ค่า name_drug , total_quantity , mode ลงในตาราง GridView คับ
โดย DataBase ตาราง Drug , mode
Drug - name_drug , quantity , id_mode
mode - id_mode , mode
โดย พอรันก็ Error เลย คับ ช่วยดูให้ทีคับ ขอบคุณคับบบบ
โดย มัน Error ว่า Column 'mode.mode' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. คับ
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
2009-08-20 13:54:10 |
By :
hero_big |
View :
1555 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |