I'm trying to run a SQL query from VB that returns an array of all unique values (Btl) for a given day, in time ascending order.
I'm working off of someone else's code and modifying from a version that only returned a single int value each day. (e.g. '1' , but I would like it to modify it to return '1 2 3 4')
I've tried to convert the 'Btl' variable to an array like 'Btl()' but I get the error that "Value of type 'Integer()' cannot be converted to 'Integer'"
'Get 'wherecl' table
Function GetBtl(ByVal tblRS As String, ByVal nday As Integer, ByVal sqlConn As
SqlConnection) As Integer
' Get the day's sample bottle
Dim wherecl As String
wherecl = "WHERE (DATEDIFF(d, { fn NOW() }, TmStamp) = " & nday & ")"
Dim Q4 As String
' SQL cmd to get array of unique bottles each day
Q4 = "SELECT distinct BottleToSample FROM " & tblRS & " " &
wherecl &
" ORDER BY TmStamp ASC;"
'End If
Dim MCGQ4 As New SqlCommand(Q4, sqlConn)
Dim Btl As Integer = MCGQ4.ExecuteScalar 'This is the bottle number
Return Btl
End Function
This version compiles, but doesn't display any results.
I would like it to deliver "1 2 3 4" for example