How Can I Pass A Value From To Bartender Ver.10? S’abonner

Legacy Poster

What data source will I use in Bartender to connect with the queried data in VB.Net? Currently, I am using the database field as my data source type. But when I print it through the use of VB.Net, it prints all the data in selected database field. For example, I have 100 data in the database, it prints 100 data but what I want is to print just the queried data, for example only 3 data were the result of the query. 

This is how my code looks like:

Imports System
Imports System.Data
Imports System.IO
Imports System.Text
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data.SqlClient
Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1
Dim btApp As BarTender.Application
Dim btFormat As BarTender.Format
Dim btMsgs As BarTender.Messages
Dim cnstr As String = "Data Source=; initial catalog=Aero; user=cats; password=dogs;"
Dim conn As New SqlConnection(cnstr)
Dim reader As SqlDataReader = Nothing

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

btApp = New BarTender.Application()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As String
Dim MyQuery As String = "Select partno from card where serialno='000001' "
Dim myCommand = New SqlCommand(MyQuery, conn)
reader = myCommand.ExecuteReader

btFormat = btApp.Formats.Open("F:\shine\Projects\Aeroscout\Bartender\aero.btw")
btFormat.SetNamedSubStringValue("partno", "")
btFormat.SetNamedSubStringValue("serialno", "")

If reader.HasRows Then
While reader.Read
i = reader(0)

btFormat.SetNamedSubStringValue("partno", reader("partno"))
btFormat.SetNamedSubStringValue("serialno", "000001")
btFormat.Print("Job1", True, -1, btMsgs)
End While
End If

End Sub

Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.FormClosed
End Sub

End Class





Thanks in advance.

1 commentaires

Domingo Rodriguez
Actions pour les commentaires Permalien

Vous devez vous connecter pour laisser un commentaire.