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. Combobox and Database

Combobox and Database

Scheduled Pinned Locked Moved Visual Basic
questiondatabasehelp
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.
  • G Offline
    G Offline
    gls2ro
    wrote on last edited by
    #1

    Hello! I have a combobox with autocomplete, and I linked this combobox with data bindings to a database. Now I want that when I choose an item to automatically go to that record in database and display the information on screen. How do I make this, to go to that record in database? PLEASE HELP ME! Thank you! Bye!

    P 1 Reply Last reply
    0
    • G gls2ro

      Hello! I have a combobox with autocomplete, and I linked this combobox with data bindings to a database. Now I want that when I choose an item to automatically go to that record in database and display the information on screen. How do I make this, to go to that record in database? PLEASE HELP ME! Thank you! Bye!

      P Offline
      P Offline
      Pugman812
      wrote on last edited by
      #2

      Create two data adapters. One with just the displayed and key field or unique field selected. And another with all the fields selected and in the key field or unique field under criteria put a "=?" no quotes. Then create datasets for both. Then you need to create Functions either in a component module or just in your forms code. They could look something like this. This is from a component *************************************************************************** Public Function getdataset(ByVal strValue As String) As DataSet 'fill the dataset DsGuests1.Clear() daGuests.SelectCommand.Parameters("Phone").Value = strValue NOTE:The "Phone" parameter will just be your unique field daGuests.Fill(DsGuests1) Return DsGuests1 End Function Public Function GetNames() As DataView 'fill the dataset daNames.Fill(DsNames1) Return dvNames End Function *************************************************************************** Then you are going to have to set up the combo box to get the displayed names by calling your dataset and putting it into a dataview object with just the displayed field as the Display Member and the Unique key field as data member when the form loads. Could look something like this. *************************************************************************** Dim dvnames As DataView dvnames = mobjguests.GetNames With Combobox1 .DataSource = dvnames .DisplayMember = "FullName" .ValueMember = "Phone" .SelectedIndex = -1 End With NOTE: mobjguests was the name of my component it would be just a procedure of getnames if you were using the form and would just be dvnames = GetNames *************************************************************************** After the names are filled in the list and you then need to set up a Combobox indexChanged event. This will call the dataset with all of the fields in it and will send the data member part of your combobox to the function. After this you are going to have to bind each of you data fields to a textbox or whatever you choice and all of this will looks something like this. *************************************************************************** Private Sub cboNames_SelectedIndexChan

      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