Need Search Code For VB using MS access as database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dismantle
    New Member
    • Jan 2007
    • 11

    Need Search Code For VB using MS access as database

    Hi all,
    I need code help to perform a search code using access database
    i tried to search other threads but only saw this thread http://www.thescripts. com/forum/thread580180.ht ml
    and its very detailed but problem is its for sql server i fink
  • maxamis4
    Recognized Expert Contributor
    • Jan 2007
    • 295

    #2
    Could you be more specific on search code?

    Comment

    • dismantle
      New Member
      • Jan 2007
      • 11

      #3
      im putting a textbox for the users to input a number and it searches for the exact number in the database and will be shown in my other textboxes

      heres my code in conencting to my databse
      con.ConnectionS tring = "Provider=Micro soft.Jet.Oledb. 4.0;Data Source=C:\Tribe ndatabase.mdb"
      con.Open()
      sql = "Select*Fro m Codes"
      da = New OleDb.OleDbData Adapter(sql, con)
      da.Fill(ds, "Virtual")

      con.Close()
      Maxrows = ds.Tables("Virt ual").Rows.Coun t
      inc = -1

      all i need now is the syntax how to do a search

      Comment

      • maxamis4
        Recognized Expert Contributor
        • Jan 2007
        • 295

        #4
        Change the sql

        Code:
        dim myValue as number
        con.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\Tribendatabase.mdb"
        
        myValue = Your_textbox.text
        
                con.Open()
                sql = "Select*From Codes where [yourfield]="myValue
        
                da = New OleDb.OleDbDataAdapter(sql, con)
                da.Fill(ds, "Virtual")
        
                con.Close()
                Maxrows = ds.Tables("Virtual").Rows.Count
                inc = -1

        Comment

        • dismantle
          New Member
          • Jan 2007
          • 11

          #5
          ok thnx ill try

          Comment

          Working...