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. General Programming
  3. Visual Basic
  4. DAO: In VB 6.0, how do i search a access database?

DAO: In VB 6.0, how do i search a access database?

Scheduled Pinned Locked Moved Visual Basic
questiondatabase
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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I am using the ADO in VB 6 and I was wondering how I could search the active database for a specific value. If someone could please give me a hand with this, that would be great!:)

    N 1 Reply Last reply
    0
    • L Lost User

      I am using the ADO in VB 6 and I was wondering how I could search the active database for a specific value. If someone could please give me a hand with this, that would be great!:)

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      Your question is a little decieving because you mention two different technologies used to access a database. I will assume you are using ADO. Here is an example to "search" a database. You will need to add a reference to the ADO object library in your program before running this code.

      Dim conn As New ADODB.Connection
      Dim adors As New ADODB.Recordset
      Dim sql As String

      sql = "SELECT User_ID Where username = '" & replace(txtUserName.Text, "'", "''") & "'"

      Set conn = New ADODB.Connection
      Set adors = New ADODB.Recordset

      conn.ConnectionString = "[YourConnectionStringGoesHere]"
      conn.Open
      adors.ActiveConnection = conn
      adors.Open (sql)
      If Not adors.EOF Then
      Do Until adors.EOF
      MsgBox txtUserName.Text & "'s user id is " & adors("User_ID")
      adors.MoveNext
      Loop
      Else
      MsgBox "There are no records that match that name"
      End If

      adors.Close
      Set adors = Nothing
      conn.Close
      Set conn = Nothing

      HTH Nick Parker
      If the automobile had followed the same development as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year killing everyone inside. -Robert Cringely


      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