Buon giorno e buona domenica a tutti...riprendo il discorso, da prove e studio consigliato gentilmente da voi "credo" di essere riuscito ed è funzionante anche con gli apici...vi posto il codice...
Private Sub searchData(sql As String, dtg As DataGridView)
Try
con.Open()
cmd = New SqlCommand()
da = New SqlDataAdapter
dt = New DataTable
With cmd
.Connection = con
.CommandText = sql
End With
With da
.SelectCommand = cmd
.Fill(dt)
End With
dtg.DataSource = dt
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
da.Dispose()
End Try
End Sub
nel load del form
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
sql = "SELECT * FROM Prova"
searchData(sql, DataGridView1)
End Sub
nella textbox
Dim strFilter As String = TextBox1.Text.Replace("'", "''")
sql = "SELECT * FROM Prova WHERE Cognome LIKE '%" & strFilter & "%' OR Nome LIKE '%" & strFilter & "%'"
searchData(sql, DataGridView1)
a voi più esperti...secondo voi sono riuscito ad usare correttamente i parametri??? se ancora no mi potete dire dove sbaglio??? cmq è tutto funzionante...GRAZIE