none
I'm getting a "oops no value given for one or more required parameters" error. Also can't figure out why it won't filter to use what is found within TextBox1 RRS feed

  • Question

  •             Try
                    connDB.Open()
                    Dim objCmd = New OleDb.OleDbCommand
                    objCmd.Connection = connDB
                    objCmd.CommandText = "SELECT        ID, [Bench points], Name, Type, BrandID
                                                FROM            Parts
                                                WHERE (Name LIKE TextBox1.text)
                                                ORDER BY [Bench points];"
                    objCmd.CommandType = CommandType.Text
                    Dim objAdpt = New OleDb.OleDbDataAdapter
                    Dim objDS = New DataSet
                    objAdpt.SelectCommand = objCmd
                    objAdpt.Fill(objDS)
                    PartsDataGridView.DataSource = objDS.Tables(0)
                Catch
                    MsgBox("Oops " + Err.Description(), MsgBoxStyle.OkOnly, "Failed to Open")
                End Try

    The program does display the data from the database, this is just the code I'm using to search through records. Wanted to use regex to make my searching less dependent on getting the string exactly equal to one in the database however it seems to difficult. Would really appreciate the help with this, Thanks

    Wednesday, January 22, 2020 9:23 PM

Answers

  • Hi Lewis Mckeating,
    Based on your code, I noticed that the error mostly caused by this statement

    WHERE (Name LIKE TextBox1.text).

    You want to use the value of TextBox instead of its property.
    So you can change your SQL statement to the following code example.

    Sql = "select * from Logic where userid like'" + textBox1.Text + "'";

    >>Wanted to use regex to make my searching less dependent on getting the string exactly equal to one in the database however it seems to difficult.
    Do you want to use Regex to do fuzzy query? If so, you can refer to following code example.

    Module regexProg
       Sub showMatch(ByVal list As List<string>, ByVal expr As String)
          Dim str As string
          For Each str In list
          Dim mc As MatchCollection = Regex.Matches(str, expr)
          Dim m As Match
          For Each m In mc
              Console.WriteLine(m)
          Next m
       End Sub
       Sub Main()
          Dim list As New List(Of String) From {"Some","Daniel","Tina","Side"}
          Console.WriteLine("Matching words that start with 'S': ")
          showMatch(list, @"S\S*")
          Console.ReadKey()
       End Sub
    End Module

    And you can get more information about Regex from this document.
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 23, 2020 8:36 AM