我在VB中有方法图像条形码我想将图像条形码保存到数据集中?在frm_Reporting中,我有水晶报表查看器并放入barcodeImage,当调用btnEncode时,创建图像条形码,然后必须插入数据集。
Private Sub Frm_Reporting_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CrystalReportViewer1.ReportSource = Nothing
Dim rptbarcode As RptPacking
rptbarcode = New RptPacking
Dim xrep As DataSet1
xrep = New DataSet1
Dim row As DataRow
Dim MyImg As Image = Nothing
Try
btnEncode(MyImg, BarcodeText)
row = xrep.Tables(0).NewRow
xrep.Tables("DataTable1").Rows(0).SetAdded = MyImg
CrystalReportViewer1.ReportSource = rptbarcode
rptbarcode.SetDataSource(xrep)
rptbarcode.PrintToPrinter(1, False, 0, 0)
Catch ex As Exception
End Try
End Sub
Private Sub btnEncode(ByRef pic As Image, ByVal txtData As String)
Dim W As Integer = 160
Dim H As Integer = 110
Dim b As BarcodeLib.Barcode
Dim type As BarcodeLib.TYPE = BarcodeLib.TYPE.UNSPECIFIED
type = BarcodeLib.TYPE.CODE128
b = New BarcodeLib.Barcode()
Try
If type <> BarcodeLib.TYPE.UNSPECIFIED Then
b.IncludeLabel = True
'===== Encoding performed here =====
pic = b.Encode(type, txtData, W, H)
'CType(Frm, frm_submitentery).pic_img.Image = pic.Image
'===================================
End If
Catch ex As Exception
'try
MessageBox.Show(ex.Message)
'catch
End Try
End Sub