0
Private Sub Btn_Rechercher_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Rechercher.Click
        Dim mycommand As New OleDbCommand()
        mycommand.CommandText = "SELECT * FROM Patient WHERE CIN_Patient=" & Me.CIN_Txt.Text
        mycommand.Connection = myconnexion
        Dim myDataAdapter As New OleDbDataAdapter(mycommand)
        Dim myDataSet As New DataSet()
        myDataAdapter.Fill(myDataSet, "Patient")
        DataGridView1.DataSource = myDataSet.Tables("Patient").NewRow()
    End Sub

They told me that it might be the type is mismatching, but still didn't get it!

braX
  • 11,506
  • 5
  • 20
  • 33
  • 1
    Which is it? VBA or VB.NET? – rory.ap May 04 '23 at 00:32
  • 3
    My guess: your table Patient defines the column CIN_Patient as number (integer, long, or other numeric datatype), but you are comparing it with some string value in a textbox CINM_Txt.Text which may hold nonnumeric data. – tinazmu May 04 '23 at 00:58
  • The following may be helpful: https://stackoverflow.com/a/69638011/10024425 – Tu deschizi eu inchid May 04 '23 at 01:21
  • @tinazmu, it would be the other way around. There are no quotes in that SQL code so the value will not interpreted as text unless the `TextBox` contains the quotes. If there are no quotes then the value is likely being interpreted as a number when it should be text. – jmcilhinney May 04 '23 at 01:50
  • 1
    What is the data type of the `CIN_PATIENT` column? Whatever it is, the value you're providing in your SQL code is not that type. Of course, you haven't bothered to show us that SQL code either, so we can only guess what it is. This issue is an example of why you should ALWAYS use parameters with ADO.NET, rather than concatenating values into strings. [Here](http://jmcilhinney.blogspot.com/2009/08/using-parameters-in-adonet.html) is my take on that subject. I suggest that you read that and then modify your code accordingly. – jmcilhinney May 04 '23 at 01:54

0 Answers0