Right now I'm working on a simple program in vb.net. Choose 2 dates in the daytimepicker, press a button for an sql-query and save the result somewhere. This works fine, but now I want to add an counter to the query. One column just has the numbers 1,2,3 in it and I want to count each one. Little example with an "output" `
x x x 1 -> count 1
x x x 1 -> count 2
x x x 2 -> count 1
x x x 1 -> count 3
x x x 2 -> count 2
x x x 3 -> count 1
` This counter then should be added to the datatable which is the result of the query, as a new column. Basicly an bill number.
I've tried to do this in the read-function of the sql, but I'm just getting errors and I dont know why..still beta I guess.
Do While myReader.Read()
results = results & myReader.GetString("0") & ";" &
myReader.GetString("1") & ";" &
myReader.GetString("2") & ";" &
myReader.GetDecimal("3") & ";" &
myReader.GetInt32("4") & ";" &
myReader.GetInt32("5") & ";" &
** thats basicly my reader, which puts an ; between everything because im saving it as .csv
If myReader.GetInt32("5") = 1 Then
nmb1 = nmb1 + 1
**put nmb1 in the output"
ElseIf myReader.GetInt32("5") = 2 Then
nmb2 = nmb2 + 1
**put nmb1 in the output"
ElseIf myReader.GetInt32("5") = 3 Then
nmb3 = nmb3 + 1
**put nmb1 in the output"
Else
MsgBox("u failed")
End If '& vbLf
Loo
p
I'll hope you understand my question, because I'm kinda new to programming. If you need any further explonation, please ask.