Results 1 to 10 of 10

Thread: Problem selecting data from DB to MSHFlexGrid

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    23

    Problem selecting data from DB to MSHFlexGrid

    Hello guys,

    im using VB6, MS Access, ADO and MSHFlexGrid
    And im having problem to fill the Flex grid with data from my database.

    I have two tables - tab_companies, tab_payments.
    And i want to load in the flex grid the payments and its information depending on the CompanyID registered to which one.
    Like, the user choose in the combobox the company, and then the CompanyID is stored in a textbox (i thought to use a variable but not sure), so the payments of that company is shown in the Flex Grid.

    I tried to make a SQL query but i doesnt work:

    Code:
    "SELECT description from tab_payments WHERE CompanyID LIKE '" & txtID.Text & "'", cn, adOpenDynamic, adLockOptimistic
    And it doesnt load any data, just the field name.

    Well, im very newbie on it, i read the tutorials but couldnt found a solution.

    If u guys could help me?

    Thanks in advance

  2. #2

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    23

    Re: Problem selecting data from DB to MSHFlexGrid

    Is the problem with the syntax?

  3. #3
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,495

    Re: Problem selecting data from DB to MSHFlexGrid

    Is companyId a number? If so remove the single qoutes around txtID.Text. Also change LIKE to =
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    23

    Re: Problem selecting data from DB to MSHFlexGrid

    It would be like this?

    Code:
    "SELECT description from tab_payments WHERE CompanyID =  txtID.Text ", cn, adOpenDynamic, adLockOptimistic
    Thx!

  5. #5
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,495

    Re: Problem selecting data from DB to MSHFlexGrid

    No

    Like this:

    Code:
    "SELECT description from tab_payments WHERE CompanyID =  " & txtID.Text, cn, adOpenDynamic, adLockOptimistic
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  6. #6

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    23

    Re: Problem selecting data from DB to MSHFlexGrid

    Ok, i changed the query and now a error message appears saying that there is a missing operator on expression CompanyID =
    What it could be?
    Last edited by corps; May 20th, 2010 at 11:35 AM.

  7. #7
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,495

    Re: Problem selecting data from DB to MSHFlexGrid

    Do you know how to set breakpoints? Print a var to the immediate window? These are things you will need to understand and do to continue programing.

    First you need to get the select statement into a var instead of the way you have it in the rs.Open command. Next print the actual contents of the var to the immediate window and post the results here.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  8. #8

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    23

    Re: Problem selecting data from DB to MSHFlexGrid

    Found the solution.

    The problem was syntax

    Code:
    "SELECT description from tab_payments WHERE CompanyID= '" & ID & "' ", cn, adOpenDynamic, adLockOptimistic
    It works now

    Thx alot!

    PS: Red Sox ftw!!

    Jks

  9. #9
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,495

    Re: Problem selecting data from DB to MSHFlexGrid

    Your welcome and I'm really sorry for you
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  10. #10

    Thread Starter
    Junior Member
    Join Date
    May 2010
    Posts
    23

    Re: Problem selecting data from DB to MSHFlexGrid

    Haha i loled

    Ok, i accept, ,this year its not a good one, but we shall overcome!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width