Friends,
I have my report working, but there has to be a better way. Right now, in my VB.net code, I perform a select statement to get the data I want, and then I insert that data into a table. After doing so, I run the report which has the database assigned, and pulls that data from that table and then builds the report.
It seems like there should be an easier way, but I don't know how. I want to eliminate that extra step of inserting into a table for one other reason. The report has that table hard mapped; which creates problems.
I'd like to just do the select statement, and while I reading the rows, insert those rows into the report instead of the table. Is that possible?
Here is the vb code where I take the selected data and insert into the table:
If dr.HasRows Then
'loop through the records
While dr.Read()
i = (i + 1)
li = lvRaceStartOrder.Items.Add
(i)
If i Mod 2 = 0 Then
li.BackColor = Color.White
Else
li.BackColor = Color.Gainsboro
End If
li.SubItems.Add(dr("StartP
osition"))
intPrintStartPosition = (dr("StartPosition")) <-- a field that is used in the report
li.SubItems.Add(dr("No"))
strPrintCarNumber = (dr("No"))
li.SubItems.Add(dr("Driver
"))
strPrintPassingTimeHours = (dr("Hours"))
strPrintPassingTimeMinutes
= (dr("Minutes"))
strPrintPassingTimeSeconds
= (dr("Seconds"))
'li.SubItems.Add(dr("Passi
ng Time"))
strPrintPassingTime = (strPrintPassingTimeHours & ":" & strPrintPassingTimeMinutes
& ":" & strPrintPassingTimeSeconds
) <-- a field that is used in the report
li.SubItems.Add(strPrintPa
ssingTime)
li.SubItems.Add(dr("Flag")
)
strDecoderID = (dr("TimeLine"))
If strDecoderID = "100" Then
strDecoderID = "Start/Finish" <-- a field that is used in the report
Else
strDecoderID = "Warning: Not Start/Finish" <-- a field that is used in the report
End If
li.SubItems.Add(strDecoder
ID)
Dim InsertRecord As New SqlClient.SqlConnection(ds
n)
'fill in the data for a lap ...
InsertData = New DataSet
Dim DataReader As SqlClient.SqlDataReader
InsertRecord = New SqlClient.SqlConnection(ds
n)
InsertRecord.Open()
Dim Command As New SqlClient.SqlCommand("Inse
rt Into PrintRaceStart Values (" & intPrintStartPosition & ", '" & strPrintCarNumber & "', '" & strPrintPassingTime & "')", InsertRecord)
DataReader = Command.ExecuteReader(Comm
andBehavio
r.SingleRe
sult)
InsertRecord.Close()
InsertRecord = Nothing
End While
End If