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.Clickoconn =
New SqlConnection(sconnstr) 'oconn.Open() Tryocmd.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 DataSet1oda.Fill(ds, "users")
orpt.SetDataSource(ds.Tables(0))
rap.Load("C:\Documents and Settings\username\My Documents\Visual Studio\Projects\crystal\WindowsApplication1\WindowsApplication1\CrystalReport1.rpt")
rap.PrintToPrinter(1,
False, 0, 0)Catch ex As Exception
MsgBox(ex.Message)
Finallyoconn.Close()
oconn =
Nothingocmd =
Nothingoda =
Nothingorpt =
Nothingrap =
Nothing End TryEnd 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

Help with crystal
jcMud
I got it to work using this
orpt.SetDataSource(ds.Tables(0))
orpt.PrintToPrinter(1, False, 0, 0)
I removed the following lines
rap.Load("C:\Documents and Settings\username\My Documents\Visual Studio\Projects\crystal\WindowsApplication1\WindowsApplication1\CrystalReport1.rpt")
rap.PrintToPrinter(1, False, 0, 0)
Would this cause any problems
Armand du Plessis
Taking a quick look at your code, it looks like you are setting the datasource for orpt object and yet opening the report as rap object. You would need to set the report document first and then set the datasource to that object.
Here is a link to the walkthroughs for Visual Studio 2005 Beta 2 including one for connecting using ADO .NET datasets:
http://www.businessobjects.com/global/pdf/dev_zone/cr_vs2005_walkthroughs.pdf
Keith - Business Objects