Torna al Thread
Dim WhereCondition As String = ""
Dim ctrl As Control
For Each ctrl In Me.Panel1.Controls
If TypeOf (ctrl) Is TextBox Then
If Not CType(ctrl, TextBox).Text.Equals("") Then
WhereCondition = WhereCondition & CType(ctrl, TextBox).Tag.ToString() & " LIKE @" & CType(ctrl, TextBox).Tag.ToString() & " AND "
cmd.Parameters.AddWithValue("@" & CType(ctrl, TextBox).Tag.ToString(), CType(ctrl, TextBox).Text)
End If
End If
Next
WhereCondition = WhereCondition.Trim()
If WhereCondition.ToUpper().EndsWith("AND") Then
WhereCondition = WhereCondition.Remove(WhereCondition.Length - 3, 3)
End If
cmd.SelectCommand = "SELECT * FROM tbMacchinario WHERE " & WhereCondition & ";",conn)