Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Query SQL DB from VB.NET

Query SQL DB from VB.NET

Scheduled Pinned Locked Moved ASP.NET
databasecsharpcssdata-structures
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MontenegroATL
    wrote on last edited by
    #1

    Hello, I am playing with ways to set query command in VB.NET to retrieve set of records from SQL DB. I know basic sytanx and it works well. However I can not get this to work. I have a textbox where users enters a name of broker and then when clicks Search button, data grid gets populated with all broker info. This works well if name that user entered exists in SQL DB. My goal was to have this same result, but when users enters partial name too. Example: Full broker name: Mike Tyson Partial broker name: Mi This is the string I used but it does not work: Dim strSQL As String = "SELECT * FROM broker where name like '" & strName& "%'" This returns error : Index was outside the bounds of the array. If I enter this command directly in SQL Analyzer as SELECT * FROM broker where name like 'Mi%' it works just fine. What I am missing???

    M 1 Reply Last reply
    0
    • M MontenegroATL

      Hello, I am playing with ways to set query command in VB.NET to retrieve set of records from SQL DB. I know basic sytanx and it works well. However I can not get this to work. I have a textbox where users enters a name of broker and then when clicks Search button, data grid gets populated with all broker info. This works well if name that user entered exists in SQL DB. My goal was to have this same result, but when users enters partial name too. Example: Full broker name: Mike Tyson Partial broker name: Mi This is the string I used but it does not work: Dim strSQL As String = "SELECT * FROM broker where name like '" & strName& "%'" This returns error : Index was outside the bounds of the array. If I enter this command directly in SQL Analyzer as SELECT * FROM broker where name like 'Mi%' it works just fine. What I am missing???

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      MontenegroATL wrote:

      Dim strSQL As String = "SELECT * FROM broker where name like '" & strName& "%'"

      Don't let Colin[^] see this code.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups