Problem on using SQL in VB6.0 with MS access Database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kwok
    New Member
    • Jun 2006
    • 12

    Problem on using SQL in VB6.0 with MS access Database

    This is a simple code.......

    Dim rst as DAO.RecordSet
    Dim my_sql As String
    Dim db As Database
    Set db = CurrentDb
    Set rst = db.OpenRecordse t("SELECT * FROM data")
    Me.display = rst(5)

    The text box in the form can display the information I need. It is work.
    However, I found a problem when I change the code to

    Dim rst as DAO.RecordSet
    Dim my_sql As String
    Dim db As Database
    Set db = CurrentDb
    Set rst = db.OpenRecordse t("SELECT * FROM data WHERE Name LIKE 'A%'")
    Me.display = rst(5)

    There is nothing in the text box......
    I am sure the Name column in the database have some data have 1st char 'A',
    however nothing found.......

    Is that any problem in my program??
    I am using MS Access 2000 in my office

    Reference:
    Visual Basic For Application
    Microsoft Access 9.0 Object Library
    OLE Automation
    Microsoft DAO 3.6 Object Library
    Microsoft Active X Data Objects 2.1 Library
  • Kwok
    New Member
    • Jun 2006
    • 12

    #2
    Problem Solved ~
    I use the code that show on the net i.e.
    'D%' is wrong
    I should use 'D*'
    So the I search nothing in the database

    Comment

    Working...