Transfer DataReader rows to a CrystalReport DataSet

Posted by lennie on Stack Overflow See other posts from Stack Overflow or by lennie
Published on 2010-03-15T04:48:36Z Indexed on 2010/03/15 4:59 UTC
Read the original article Hit count: 459

Filed under:
|

Please help me as I am a newbie using VB.NET. I have been asked to transfer rows from a DataReader into a Crystal Report dataset.

Here are the coding:

Private Sub BtnTransfer()
   dim strsql as string = "Select OrderID, OrderDate from ORDERS"
   dim DS as new dataset1   '<---crysal report dataset1.xsd
   dim DR as SqlDataReader
   dim RW as DataRow = DS.Tables(0).NewRow

   sqlconn = new sqlconnection(ConnString)
   sqlcmd = new sqlCommand(strSql, sqlconn)
   sqlcmd.Connection.open()

   DR = sqlcmd.ExecuteReader(CommandBehaviour.CloseConnection)
   Do while DR.Read
      RW("OrderID") = DR("OrderID")
      RW("OrderDate") = DR(OrderDate")
      DS.Tables(0).Rows.ADD(RW)
   Loop

End sub

© Stack Overflow or respective owner

Related posts about dataset

Related posts about crystal-reports