Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Sep 22, 2018 2:17 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: DatabaseQuery control: accept parameters?
PostPosted: Wed Oct 26, 2005 10:19 am 
Offline

Joined: Tue Oct 04, 2005 5:20 pm
Posts: 50
I've got a databasequery control bound to a list box, and it works great if I write a query to bring back all records in the table.

I want to be able to limit the results based on the value of a global variable. Is there a way to do this with this control?

Thanks.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Oct 26, 2005 11:03 am 
Offline
User avatar

Joined: Wed Sep 28, 2005 8:39 am
Posts: 9341
Location: St Augusta, MN
Moved to databases to be more accurate.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Oct 26, 2005 4:19 pm 
Offline

Joined: Wed Sep 28, 2005 8:30 am
Posts: 5479
Location: Austin, TX
You can limit the results shown by changing the query that is being run. Just set the SQLQuery property to the SQL statement that will only return the records that you are looking for and then call RunQuery.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Oct 26, 2005 4:37 pm 
Offline

Joined: Tue Oct 04, 2005 5:20 pm
Posts: 50
I am using the SQLQuery property via RunQuery but...

I need to be able to limit by using a query parameter. Specifically a global variable. This query works:

select title,worksheetid from worksheet where objecttype = 'test' and closed = 'false'


I need to modify the above by adding the global variable - which isn't a string
I'm assuming something like this:

select title,worksheetid from worksheet where objecttype = 'test' and closed = 'false' and teacherid = globalTeacherId


The globalTeacherId isn't resolving though...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Oct 26, 2005 4:49 pm 
Offline

Joined: Wed Sep 28, 2005 8:30 am
Posts: 5479
Location: Austin, TX
You will need to construct your sql statement as a string and then pass it in. Here is an example of what I mean:

dim sql as string

sql = "select title,worksheetid from worksheet where objecttype = 'test' and closed = 'false' and teacherid = "+ format(globalTeacherId,"0")
databaseQuery.sqlQuery = sql
databaseQuery.runQuery


As you can see you are building the sql statement and can place any data in there. Then when you will pass that string in as the query.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Oct 26, 2005 9:41 pm 
Offline

Joined: Tue Oct 04, 2005 5:20 pm
Posts: 50
Works Perfect!

Thanks for your patience and clear explanation.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group