Jon, this sub works fine:
Private Sub btnVai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVai.Click
Try
ds.Clear()
ds.Dispose()
ds = New DataSet()
DataGrid1.DataSource = Nothing
DataGrid1.DataMember = Nothing
DataGrid1.SetDataBinding(Nothing, "")
cn.ConnectionString = cnString
cn.Open()
If txtQuery.SelectedText = "" Then
da.SelectCommand.CommandText = txtQuery.Text
Else
da.SelectCommand.CommandText = txtQuery.SelectedText
End If
da.Fill(ds, "Temp")
DataGrid1.DataSource = ds
DataGrid1.DataMember = "Temp"
lblRighe.Text = ds.Tables("Temp").Rows.Count & " righe selezionate"
Catch ex As OleDb.OleDbException
MsgBox("Istruzione SQL non valida", MsgBoxStyle.Critical, "Errore di sintassi SQL")
Finally
cn.Close()
cn.Dispose()
End Try
End Sub