Hi,
Based on your description and specially the fillorders method you shared, I assume that you want to get the data from that database, and that data should has this option its
Item_Name should like the items listed in ListBox1, right?
If I misunderstood anything, please feel free to let me know.
In this case, the key task is to generate the sql query, then fill the dataset which will be the datasource of that DataGridView. The way you shared will use different sql query to fill that datagridview multiple times, in this case, we just
need one sql query.
You could use the following way to generate that sql query.
Dim qry As String = "SELECT * from Item "
Dim lst As New List(Of String)
For i = 0 To ListBox1.Items.Count - 1
Dim st As String = ListBox1.Items(i).ToString()
lst.Add(String.Format(" Item_Name LIKE '%{0}%' " _
, ListBox1.Items(i).ToString()))
Next
If lst.Count > 0 Then
qry += " where " +String.Join(" or ", lst.ToArray())
End If
Then use that query to get that data and fill the dataset to get that datagridview show the result.
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.