Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Apr 23, 2017 10:32 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: How to initiate SQL table column from variable
PostPosted: Mon Apr 22, 2013 9:01 pm 
Offline

Joined: Sat Mar 15, 2008 8:14 am
Posts: 161
Location: Montreal, Quebec, Canada
I everyone
im trying to create Sql table with column came from a variable
So im try this line but i doesnt work... even if i dont have a error message from DB
my variable call b and it contains concanate version of my listbox column with comma
and it appear like this in a messagebox " Name,Phone,Email "
App.OrdersDB.SQLExecute "Create Table test ((Str(b)) Varchar)"

in fact i need help to insert variable in sql in CREATE table...INSERT data and SELECT statement
thanks

_________________
--------------------
RB 2011r4 on win7


Top
 Profile  
 
 Post subject: Re: How to initiate SQL table column from variable
PostPosted: Mon Apr 22, 2013 9:25 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
First, build the string in a variable and examine it in the debugger. Use string concatenation, eg.,

dim sql as string
sql = "Create table test ((" + b + ") Varchar)"
break // to examine the results
App.OrdersDB.SQLExecute(sql)


Top
 Profile  
 
 Post subject: Re: How to initiate SQL table column from variable
PostPosted: Tue Apr 23, 2013 3:08 am 
Offline

Joined: Sat Mar 15, 2008 8:14 am
Posts: 161
Location: Montreal, Quebec, Canada
thank you timhare
iv just remove a set of paranthese and it work
sql = "Create table test (" + b + " Varchar)"

result
Create table test (Name,Phone,Email Varchar)
But it apply varchar only on the last column...is there a way to apply Varchar to all added column.
Do i have to insert it in my concatenate function?
And i try to apply same logic to insert... where can i find example
because
sql = "Insert into test ("+ b + Values ('Winnie','Sales','3500')")
Doesnt work either :(

_________________
--------------------
RB 2011r4 on win7


Top
 Profile  
 
 Post subject: Re: How to initiate SQL table column from variable
PostPosted: Tue Apr 23, 2013 3:29 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Dralion wrote:
thank you timhare
iv just remove a set of paranthese and it work
sql = "Create table test (" + b + " Varchar)"

result
Create table test (Name,Phone,Email Varchar)
But it apply varchar only on the last column...is there a way to apply Varchar to all added column.
Do i have to insert it in my concatenate function?

Most likely.

Quote:
And i try to apply same logic to insert... where can i find example
because
sql = "Insert into test ("+ b + Values ('Winnie','Sales','3500')")
Doesnt work either :(

You're missing a quote mark. Check the string in the debugger and adjust until you get what you want. Writing one language (sql) inside another language (RB) is always a challenge. But the debugger is your friend.


Top
 Profile  
 
 Post subject: Re: How to initiate SQL table column from variable
PostPosted: Tue Apr 23, 2013 9:00 am 
Offline

Joined: Sat Mar 15, 2008 8:14 am
Posts: 161
Location: Montreal, Quebec, Canada
Thanks Timhare
Quote:
the debugger is your friend.
Now i know what it mean and yes i gonna use it much more

_________________
--------------------
RB 2011r4 on win7


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

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group