'*** for Logo Sub Report (Start) ***'
Dim dtLogo As New DataTable("logo")
Dim dr As DataRow
dtLogo.Columns.Add(New DataColumn("Logo", GetType(System.Byte())))
dtLogo.Columns.Add(New DataColumn("Company", GetType(String)))
Dim fiStream As New FileStream(Server.MapPath("Images/thaicreate.jpg"), FileMode.Open)
Dim binReader As New BinaryReader(fiStream)
Dim pic() As Byte = {}
pic = binReader.ReadBytes(fiStream.Length)
dr = dtLogo.NewRow
dr("Logo") = pic
dr("Company") = "ThaiCreate.Com Co,. LTD"
dtLogo.Rows.Add(dr)
fiStream.Close()
binReader.Close()
'*** for Logo Sub Report (End) ***'
สร้าง Sub Report (Subreport) บน Crystal Report แบบ Step by Step (VB.NET /C#)
Call Report(bsquatationReport(bsquatationReport.Position)("QuatationID").ToString, New rptQuatation)
Sub Report(ByVal QuatationID As String, ByVal rptObj As Object)
Dim mySqlCommand1 As New MySqlCommand
Dim dtTable As New DataTable
Dim da As New MySqlDataAdapter
Dim sqlCONN As String
'=========================Report
Dim sql As String
sql = "select tblquatation.*,tblquatationdetail.* from tblquatation,tblquatationdetail where tblquatation.QuatationID=tblquatationdetail.QuatationID and tblquatationdetail.QuatationID like '%" & QuatationID & "%'"
If Conn.State = ConnectionState.Closed Then Conn.Open()
mySqlCommand1 = New MySqlCommand(sql, Conn)
da = New MySqlDataAdapter
da.SelectCommand = mySqlCommand1
dtTable = New DataTable
da.Fill(dtTable)
If Conn.State = ConnectionState.Open Then Conn.Close()
'DataGridView1.DataSource = dtTable
'---------------------------------------- Add Column Image TO Dataset ---------------------------------------------------
Dim dtMap As New DataTable("DataSet1") '*** DataTable Map DataSet.xsd ***'
Dim dr As DataRow
dtMap.Columns.Add(New DataColumn("pics", GetType(System.Byte())))
'------------------------------------------------------------------------------------------------------------------------
Dim i As Integer = 0
For i = 0 To dtTable.Rows.Count - 1
'------------------------------------------------- Application.StartupPath & "\img\" & ฟิลด์ Path รูปภาพ
Dim fiStream As New FileStream(Application.StartupPath & "\img\" & dtTable.Rows(i)("Drawing"), FileMode.Open)
Dim binReader As New BinaryReader(fiStream)
Dim pic() As Byte = {}
pic = binReader.ReadBytes(fiStream.Length)
dr = dtMap.NewRow
dr("pics") = pic
dtMap.Rows.Add(dr)
fiStream.Close()
binReader.Close()
Next
Dim rpt As New rptQuatation
rpt.SetDataSource(dtMap)
Me.CrystalReportViewer1.ReportSource = rpt
End Sub