Hi,
I am trying to print direct to printer using crystal in vs. Here is part of
my code.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
oconn = New SqlConnection(sconnstr)
'oconn.Open()
Try
ocmd.Connection = oconn
ocmd.CommandText = "select user_id,user_name from users where user_id = 1"
ocmd.CommandType = CommandType.Text
oda.SelectCommand = ocmd
Dim ds As New DataSet1
oda.Fill(ds, "users")
orpt.SetDataSource(ds.Tables(0))
rap.Load("C:\Documents and Settings\username\My Documents\Visual
Studio\Projects\crystal\WindowsApplication1\Window sApplication1\CrystalReport1.rpt")
rap.PrintToPrinter(1, False, 0, 0)
Catch ex As Exception
MsgBox(ex.Message)
Finally
oconn.Close()
oconn = Nothing
ocmd = Nothing
oda = Nothing
orpt = Nothing
rap = Nothing
End Try
End Sub
When the button is clicked the page is printed only with the column headers.
I checked my sql statement against the database and it returns 1 row. I
checked to see if the dataset is populated using
MsgBox(ds.Tables(0).Rows(0).Item(1).ToString)
The dataset has the correct data. The dataset is an .xsd file created
manually.
Any ideas?
Thanks