Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sCon As String = "Server=....;uid=....;database=....."
Dim con As SqlConnection = New SqlConnection(sCon)
Dim cmd As SqlCommand = New SqlCommand("select QstHdr.qst , avg(MRCEVD.suf) From MRCEVH INNER JOIN MRCEVD ON MRCEVH.rowid = MRCEVD.mrcevh_rowid
INNER JOIN QstHdr ON MRCEVD.seq = QstHdr.seq where Month(MRCEVH.adm_dte) = '08' and YEAR(MRCEVH.adm_dte) = '2020' and MRCEVD.seq = '1' and QstHdr.typ = 'MRC2'
and MRCEVD.suf <> '9' group by QstHdr.rowid , QstHdr.qst")
Dim sda As SqlDataAdapter = New SqlDataAdapter
Try
cmd.Connection = con : con.Open()
sda.SelectCommand = cmd
Dim dt As DataTable = New DataTable
sda.Fill(dt)
' BIND DATABASE WITH THE GRIDVIEW.
GridView1.DataSource = dt
GridView1.DataBind()
Catch ex As Exception
Label1.Text = "error"
End Try
End Sub
พอกดปุ่มคลิ๊กไม่มีอะไรเกิดขึ้น โปรดชี้แนะด้วยค้าบ
อยากได้ผลลัพธ์แบบนี้
อันนี้เป็นคำสั่ง SQL ครับ
Code (SQL)
select QstHdr.qst , avg(MRCEVD.suf) From MRCEVH INNER JOIN MRCEVD ON MRCEVH.rowid = MRCEVD.mrcevh_rowid
INNER JOIN QstHdr ON MRCEVD.seq = QstHdr.seq where Month(MRCEVH.adm_dte) = '08' and YEAR(MRCEVH.adm_dte) = '2020' and MRCEVD.seq = '1' and QstHdr.typ = 'MRC2'
and MRCEVD.suf <> '9' group by QstHdr.rowid , QstHdr.qst