|
Post by davos1 on Feb 21, 2009 12:57:52 GMT -5
Hi, How can I set the value inside a columname to a textbox? I am trying to retrieve records columnames and values in a kind of table with edit... I am retrieving the columname$ from any table, then when I try to retrieve the value according to that columname$ i got errors. supose that columnname$="company" and #row company$()="acme" I am trying to get cn$=#s columnname$() rem cn$="company," 'also I have removed the ',' in cn$. cn$=company #row= #s #nextrow() value$="#s "+cn$+"$()" 'value$='#s company$()' now, how can I set the value to the textbox? textbox #cn$, #value$
|
|
|
Post by Psycho on Feb 21, 2009 17:35:36 GMT -5
Provided that value$ now contains the correct information it would be: textbox #cn$, value$
John "Psycho" Siejkowski
|
|
|
Post by davos1 on Feb 22, 2009 17:22:54 GMT -5
hi, no, that does not work. that oly writes the string #s company$() on the textbox, but that does not pass the real value of the field #s company$() . any idea how to read the name of any columnname$ and then pass the value of that field for that columnname$ to any textbox? thanks a lot
|
|
|
Post by Carl Gundel - admin on Feb 23, 2009 10:41:12 GMT -5
You cannot dynamically get the contents of a column like that.
I'm a little confused about why you put the #s inside of quotation marks.
-Carl
|
|
|
Post by davos1 on Feb 23, 2009 14:58:40 GMT -5
Hi, I put the # because I saw another example: cssid #len2, "{width:20px}" for i = 1 to 30 hVar$="#a";i textbox #hVar$, a$ #hVar$ setid("len2") #hVar$ text(i) if i mod 5=0 then print next i so, if this example pass #a to the textbox dinamically, I assumed that using nextrow with the columnname option it could pass directly he value from #row columnname$(). (without explicit typing of the name of the columnname, allowing this routine to work with any selected column from any table... If I type in the program textbox #tb, #r company() it passes the value "acme" , so I was wondering how to pass it dinamically it we already have the name of the colummane$...
|
|
|
Post by StefanPendl on Feb 24, 2009 2:48:54 GMT -5
The example uses a handle variable to reuse the code for more than one text box.
A table is very different from using multiple text boxes.
If you find a way to do what you like with JS, then Carl and Scott might be able to include this in an upcoming release.
|
|
|
Post by Carl Gundel - admin on Feb 24, 2009 7:45:58 GMT -5
The example uses a handle variable to reuse the code for more than one text box. A table is very different from using multiple text boxes. If you find a way to do what you like with JS, then Carl and Scott might be able to include this in an upcoming release. I'm not sure how Javascript is related to this. It seems like what he needs is an eval$() function, or perhaps a getByName$() function: #row getByName$(columnname$) -Carl
|
|
|
Post by kokenge on Feb 24, 2009 13:15:22 GMT -5
Not sure, But I think I have an example of what you are trying to do. Given a database, it finds the tables, Given the table, it finds the field names an their attributes. You can look at the code and rip out the sections you need here: www.dkokenge.com/rbp/ftp/sqlite.zipIt has docs, so you can decide if it has what you want. HTH
|
|
|
Post by davos1 on Feb 25, 2009 14:45:49 GMT -5
or perhaps a getByName$() function: getByName$() function: #row getByName$(columnname$) -Carl ---------------------------------- Yes,something like that would be great to pass the values directly from the database to textboxes. #textbox, #tb, #row getByName$(a$) where a$ is a column name. ps. .thanks for the zip file, I am reading it...
|
|
|
Post by kokenge on Feb 25, 2009 18:23:18 GMT -5
I still like the dynamic variable that was discussed over a year ago. It will work, adds a lot of power, and solves a lot of other problems. For example if x$ = "client" then x$$ = '123' is the same as client$ = '123' To create textboxes from a DB would look like this sql$ = "SELECT aa,bb,cc FROM table" #sql1 execute(sql1$) colNames$ = #sql1 columnnames$() j = 1 #row = #sql #nextrow() while word$(colNames$,j,",") <> "" x$ = (word$(colNames$,j,",") x$$ = #x$ #row x$$() textbox #a$,#row$ a$$(),40 j = j + 1 WEND
if x$ is equal to "aa" then x$$ is the same as aa$ therefore x$$ = #x$ #row x$$(),40 is the same as aa$ = #aa #row aa$(),40 It also makes loads from xls files into memory or a DB simple. Usually the first line of the xls has the column names that can be used in a loop. When generating code from variables is also simple.
|
|