|  |  | 
          
            | ผมดึงข้อมูลจาก Code ด้านล่างแล้วเอาไปออกรายงาน   ทดสอบดึงได้ 7 บรรทัด โดยดึงจาก 2 ตาราง ForestMaster กับ ForestMasterSub
 เวลารันโปรแกรมเรียกรายงานมันดันออกมา 119 บรรทัด เหมือนกับว่ามันเอา 7 บรรทัดนั้นออกซ้ำกันอันละ 17 บรรทัด
 (ตาราง ForestMasterSub  มี 17 บรรทัด)
 
 แต่ Code sql มันดึงออกมาได้ 7 หรือว่ามต้องไปตั้งค่า หรือเลือกอะไรใน Report อีกหรือป่าวคับ
 
 Code (VB.NET)
 
  Private Sub Bnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bnok.Click
        If DTP1.Value > DTP2.Value Then
            MessageBox.Show("กรุณาระบุวันที่ที่ต้องการดูข้อมูลให้ถูกต้อง", "รายงานการตรวจสอบอาการผู้ป่วย", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            DTP1.Focus()
            Exit Sub
        End If
        sql = "SELECT dbo.ForestMaster.species, dbo.ForestMaster.artifact, dbo.ForestMaster.width, dbo.ForestMaster.long, dbo.ForestMaster.high, dbo.ForestMaster.remaining, "
        sql &= " dbo.ForestMasterSub.receive_in, dbo.ForestMasterSub.distribute, dbo.ForestMaster.SumAll"
        sql &= " FROM dbo.ForestMaster INNER JOIN"
        sql &= " dbo.ForestMasterSub ON dbo.ForestMaster.DoconRe = dbo.ForestMasterSub.DoconRe"
        sql &= " where ForestMasterSub.status != 'YesNe' order by ForestMasterSub.ROWORDERID ASC "
        da = New SqlDataAdapter(sql, cn)
        dt = New DataTable
        da.Fill(dt)
        Dim frp As New FrmView
        Dim rp1 As New ReArtifactOfMonth
        rp1.Database.Tables(0).SetDataSource(dt)
        ':::::::::::::เปิด Report โดยไม่ถามรหัสผ่าน:::::::::::::::::::::
        Dim strDataReport As String = ""
        Dim crtable As CrystalDecisions.CrystalReports.Engine.Table
        Dim crTableLogonInto As CrystalDecisions.Shared.TableLogOnInfo
        Dim cnConnInto As New CrystalDecisions.Shared.ConnectionInfo
        With cnConnInto
            cnConnInto.ServerName = "server2005"
            cnConnInto.DatabaseName = Database_csw.Trim
            cnConnInto.UserID = "sa"
            cnConnInto.Password = "1234"
        End With
        For Each crtable In rp1.Database.Tables
            crTableLogonInto = crtable.LogOnInfo
            crTableLogonInto.ConnectionInfo = cnConnInto
            crtable.ApplyLogOnInfo(crTableLogonInto)
        Next
        frp.objrp = rp1
        frp.Show()
    End Sub
 อันนี้หน้าออกแบบ report
 ต้องทำอะไรเพิ่มอีกไหมคับ
 
  
 
 
 Tag : .NET, Ms SQL Server 2005, VB.NET
 
 
 |  
            | 
 ประวัติการแก้ไข
 2015-03-24 17:55:40
 2015-03-24 20:11:14
 |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2015-03-24 17:53:35 | By :
                          TheCom | View :
                          854 | Reply :
                          2 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |