-
May 19th, 2010, 12:25 PM
#1
Thread Starter
Junior Member
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
-
May 20th, 2010, 06:42 AM
#2
Thread Starter
Junior Member
Re: Problem selecting data from DB to MSHFlexGrid
Is the problem with the syntax?
-
May 20th, 2010, 07:11 AM
#3
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
-
May 20th, 2010, 09:15 AM
#4
Thread Starter
Junior Member
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!
-
May 20th, 2010, 09:22 AM
#5
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
-
May 20th, 2010, 11:28 AM
#6
Thread Starter
Junior Member
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.
-
May 20th, 2010, 11:42 AM
#7
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
-
May 20th, 2010, 12:02 PM
#8
Thread Starter
Junior Member
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
-
May 20th, 2010, 12:05 PM
#9
Re: Problem selecting data from DB to MSHFlexGrid
Your welcome and I'm really sorry for you
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
May 20th, 2010, 12:20 PM
#10
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|