Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Trying to update an old vb6 project, the query i am trying to run is working correctly when run on Access query builder, but when i copy this same query and try to run within vb6 it showing me error "error: no value given for one or more required parameters"

My query is:
VB
rs_store.Open ("SELECT store_exp.type, Sum(store_exp.amount) AS SumOfamount, First(store_exp.[amt type]) AS [FirstOfamt type] From store_exp GROUP BY store_exp.type"), cn


What I have tried:

working correctly in access query builder.
Posted
Updated 9-Jul-18 23:08pm
v2
Comments
CHill60 10-Jul-18 5:07am    
What if you get rid of the brackets () ?

1 solution

Either remove the parentheses
VB
rs_store.Open "SELECT store_exp.type, Sum(store_exp.amount) AS SumOfamount, First(store_exp.[amt type]) AS [FirstOfamt type] From store_exp GROUP BY store_exp.type", cn
or pass all parameters including the optional ones enclosed by parentheses:
VB
rs_store.Open("SELECT store_exp.type, Sum(store_exp.amount) AS SumOfamount, First(store_exp.[amt type]) AS [FirstOfamt type] From store_exp GROUP BY store_exp.type", cn, adOpenForwardOnly)
 
Share this answer
 
Comments
Sheraz M 10-Jul-18 9:35am    
Tried both but not working
Either remove the parentheses - error expected expression
or pass all parameters including the optional ones enclosed by parentheses - same error not value given for one or more required parameters
Jochen Arndt 10-Jul-18 9:56am    
Are you still using VB6 or VB.Net?

However, the second version still misses one or more parameter. Just check the documentation of the Open() function for the required parameters and add them. I would have done this initially but did not do so due to the lack of information about the type of rs_store (which would indicate the kind of database interface you are using).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900