Hi Guys,
I have a function that returns a Datatable. I am passing a list of Integer as an argument. Then I thought tis would work.
as you can see. I use string.join to convert the list of integer to something like this. '1,2,3'. Problem is that is read as a string so i get the incorrect results. I need to have where EventType IN(1,2,3). what is the best fix here. Please helpCode:Public Function GetEventsByEventType(ByVal EventType As List(Of Integer), ByVal DayInterval As Integer) As DataTable Using con As New MySqlConnection(strCon) If Not EventType Is Nothing Then Dim cmd As MySqlCommand = New MySqlCommand("SELECT ID,Activity,Teams,Venue,Timing,Eventdate FROM tblcal WHERE ((EventDate >= CURDATE()) AND (EventDate <= DATE_ADD(CURDATE(), INTERVAL 7 DAY))) AND (EventType IN(?EventType)) ORDER BY EventDate;", con) cmd.Parameters.AddWithValue("?DayInterval", DayInterval) cmd.Parameters.AddWithValue("?EventType", String.Join(",", EventType)) con.Open() Dim reader As MySqlDataReader = cmd.ExecuteReader _data.Load(reader) con.Close() reader.Close() cmd.Dispose() Return _data End If End Using End Function




Reply With Quote