Transfer DataReader rows to a CrystalReport DataSet
- by lennie
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