VB.NET MySQL在多列中显示单列数据

VB.NET MySQL在多列中显示单列数据,mysql,vb.net,crystal-reports,Mysql,Vb.net,Crystal Reports,我有一个MySQL表,如下所示 ---------------------------------------------------------- | id | student_id | amount | date | purpose | ---------------------------------------------------------- | 1 | 1 | 3000.00 | 01/01/2016 | Admission

我有一个
MySQL
表,如下所示

----------------------------------------------------------
| id | student_id |  amount  |    date    |    purpose   |
----------------------------------------------------------
| 1  |    1       |  3000.00 | 01/01/2016 | Admission    |
| 2  |    1       |   600.00 | 05/01/2016 | 1st Inst.    |
| 3  |    1       |   600.00 | 06/01/2016 | 2nd Inst.    |
----------------------------------------------------------
-------------------------------------------------------------
| student_id | Admission | 1st Inst. | 2nd Inst. | tot_paid |
-------------------------------------------------------------
|    1       |   3000.00 | 600.00    | 600.00    | 4200.00  |
-------------------------------------------------------------
现在我想显示它(在水晶报告)如下

----------------------------------------------------------
| id | student_id |  amount  |    date    |    purpose   |
----------------------------------------------------------
| 1  |    1       |  3000.00 | 01/01/2016 | Admission    |
| 2  |    1       |   600.00 | 05/01/2016 | 1st Inst.    |
| 3  |    1       |   600.00 | 06/01/2016 | 2nd Inst.    |
----------------------------------------------------------
-------------------------------------------------------------
| student_id | Admission | 1st Inst. | 2nd Inst. | tot_paid |
-------------------------------------------------------------
|    1       |   3000.00 | 600.00    | 600.00    | 4200.00  |
-------------------------------------------------------------
我的代码是

Dim st_id As String = String.Empty
Dim adm As Integer = 0
Dim fst As Integer = 0
 Dim scnd As Integer = 0
 Dim total_paid As Integer = 0

 OpenConnection()
 Dim dbcommand As New MySqlCommand
 Dim dbadapter As New MySqlDataAdapter
 Dim dt As New DataTable
 dt.Columns.Add("st_id")
 dt.Columns.Add("admission", GetType(Integer))
 dt.Columns.Add("first", GetType(Integer))
 dt.Columns.Add("second", GetType(Integer))
 dt.Columns.Add("total_paid", GetType(Integer))

 Dim qry As String = "Select " & _
 "fee_payment.st_id AS st_id," & _
 "fee_payment.amt AS amt," & _
 "fee_payment.purpose AS purpose," & _
 "From " & _
 "fee_payment Inner Join " & _
 "master_student On master_student.st_id = fee_payment.st_id WHERE course='" & course & "' GROUP BY st_id"
 dbcommand.Connection = conn
 dbcommand.CommandText = qry
 Dim dr As MySqlDataReader = dbcommand.ExecuteReader
 While dr.Read
      Dim st_id= dr("st_id")
      Dim amt = dr("amt")
      Dim purpose = dr("purpose")

      If purpose = "ADMISSION" Then
                adm = amt
            Else
                adm = 0
            End If
            If purpose = "1st Inst." Then
                fst = amt
            Else
                fst = 0
            End If

            If purpose = "2nd Inst." Then
                scnd = amt
            Else
                scnd = 0
            End If

            total_paid = adm + fst + scnd

            Dim R As DataRow = dt.NewRow
            R("st_id") = st_id
            R("admission") = adm
            R("first") = fst
            R("second") = scnd
            R("total_paid") = total_paid
            dt.Rows.Add(R)
        End While
        dr.Close()


        Dim stdata As New DataSet()
        stdata.Tables.Add(dt)
        stdata.WriteXml(Application.StartupPath & "\ReportXml\duelist.xml", XmlWriteMode.WriteSchema)
生成报告时,它仅显示第一条记录,即
准入
目的。没有显示其他记录


我该怎么办?

当您要将行转换为行时,它被称为轴cols@Plutonix ...... 我知道这是一个支点。在我的例子中,我应该怎么做呢?当你想把行转换成行时,它被称为pivotcols@Plutonix ...... 我知道这是一个支点。就我而言,我该怎么做?