Question for anyone who has used parameter queries in querydef objects under VB 
Author Message
 Question for anyone who has used parameter queries in querydef objects under VB

Hello,
        I'm trying to use a parameter of type TABLEID so I can pass table
names to the querydef object at run time.  This is what I have:
 Dim q As querydef
 Dim ssql As String
 Dim db As database

Set db = OpenDatabase("g:\projects\mple\input\mpf.mdb")

ssql = "parameters myvalue text, thetable tableid; INSERT INTO it_itms IN
'g:\projects\mple\input\template.mdb' SELECT it_itms.* FROM thetable where
it_itms.it_itm_id = myvalue;"

 Set q = db.OpenQueryDef("copy")
 q.SQL = ssql
 q!myvalue = "ab"
 q!thetable = "it_itms"
 q.Execute

This results in a GPF in vb.exe under Win95.  GPF occurs only when I use
tableid.  Anyone know what I'm dong wrong?
                Thanks in advance,
                                -=Matthew=-




Thu, 11 Dec 1997 03:00:00 GMT  
 Question for anyone who has used parameter queries in querydef objects under VB

Quote:
> I'm trying to use a parameter of type TABLEID so I can pass table
> names to the querydef object at run time.  

3 comments, and a suggestion for fixing it:

If you can do it with parameters, then you might as well use a stored query.
They're much quicker than SQL (no parse overhead)

If you're building the SQL string, then you don't need parameters. Use some
VB  string handling to build exactly the query you need, and avoid the need
for parameters.

There's no need to use a stored query and change its SQL property. You can
execute the SQL directly.

Quote:
> This results in a GPF in vb.exe under Win95.  

Don't know why. Try simplifying it and see if it still does it.
Do you still get a GPF with a stored qurery & no parameters ?
Do you get one with a query built out of SQL & no parameters ?

Can't say I've ever used tableid. I've always built awkward names into SQL
strings rather than passing them as parameters.

--

Database development for mailorder, marketing & general business users.



Sat, 13 Dec 1997 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Question for anyone who has used parameter queries with querydef objects in VB

2. Newbiw having problems with Permanent QueryDef: Query input must contain at least one table or query

3. Parameter Queries Error using QueryDef

4. Passing Parameters to stored parameter queries using VB 5's Data Controls

5. To Few Parameter, Expecting XX in Querydef object

6. Update query with querydef object

7. Silly question -- Parameter Query using DBGrid.

8. Help! Cannot specify parameters using QueryDef in ODBCDirect

9. Using Parameters in QueryDef bound to Data Control

10. Silly question -- Parameter Query using DBGrid.

11. Silly question -- Parameter Query using DBGrid.

12. Data control using an Access QueryDef *with* parameters.

 

 
Powered by phpBB® Forum Software