New topic: How to initiate SQL table column from variable
<http://forums.realsoftware.com/viewtopic.php?t=47674> Page 1 of 1 [ 5 posts ] Previous topic | Next topic Author Message Dralion Post subject: How to initiate SQL table column from variablePosted: Mon Apr 22, 2013 9:01 pm Joined: Sat Mar 15, 2008 8:14 am Posts: 157 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 timhare Post subject: Re: How to initiate SQL table column from variablePosted: Mon Apr 22, 2013 9:25 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 12262 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 Dralion Post subject: Re: How to initiate SQL table column from variablePosted: Tue Apr 23, 2013 3:08 am Joined: Sat Mar 15, 2008 8:14 am Posts: 157 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 timhare Post subject: Re: How to initiate SQL table column from variablePosted: Tue Apr 23, 2013 3:29 am Joined: Fri Jan 06, 2006 3:21 pm Posts: 12262 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 Dralion Post subject: Re: How to initiate SQL table column from variablePosted: Tue Apr 23, 2013 9:00 am Joined: Sat Mar 15, 2008 8:14 am Posts: 157 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 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 5 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
