Kobus
11-06-2009, 10:34 PM
Hello,
After trying almost everything (I think I am sooo good at trying all the wrong coding) I finally discovered working code for adding column data to comboboxes.
s$ = sqlOpen(AppPath$ + "DB_X.sql");
if (s$ == 0)
ShowMessage(SQLError$);
End;
rc$ = SqlGetTable(s$, "SELECT A, B, C, D FROM Table_A a", &data$, &row$, &column$);
if (rc$ <> SQLITE_OK)
ShowMessage(SQLERROR$);
end;
i$ = 4;
While(data$[i$] <2)
ComboBox_Add(Input1$, data$[i$]);
i$ = i$+4;
End;
In this sample 4 columns (A, B, C and D) are selected from a table (Table_A in this example - don't forget the "a" after the table name).
For adding data from one column to a Combobox I used column A, which has the index: 0
To skip the columns' name, set a variable (i$ in this sample) to the value 4.
All column header names are skipped now, because I selected 4 columns from the table.
'For' neither 'ForEach' gave the correct output so I tried 'While' and that does what I wanted. Input1$ is the Name of the combobox I used and i$ = i$+4; raises the index with 4, the number of colums selected from the table.
So when you select a complete table you have to count, set the index to the correct starting column (start counting from zero) and raise the index by using the same number.
Greetz,
Helen.
After trying almost everything (I think I am sooo good at trying all the wrong coding) I finally discovered working code for adding column data to comboboxes.
s$ = sqlOpen(AppPath$ + "DB_X.sql");
if (s$ == 0)
ShowMessage(SQLError$);
End;
rc$ = SqlGetTable(s$, "SELECT A, B, C, D FROM Table_A a", &data$, &row$, &column$);
if (rc$ <> SQLITE_OK)
ShowMessage(SQLERROR$);
end;
i$ = 4;
While(data$[i$] <2)
ComboBox_Add(Input1$, data$[i$]);
i$ = i$+4;
End;
In this sample 4 columns (A, B, C and D) are selected from a table (Table_A in this example - don't forget the "a" after the table name).
For adding data from one column to a Combobox I used column A, which has the index: 0
To skip the columns' name, set a variable (i$ in this sample) to the value 4.
All column header names are skipped now, because I selected 4 columns from the table.
'For' neither 'ForEach' gave the correct output so I tried 'While' and that does what I wanted. Input1$ is the Name of the combobox I used and i$ = i$+4; raises the index with 4, the number of colums selected from the table.
So when you select a complete table you have to count, set the index to the correct starting column (start counting from zero) and raise the index by using the same number.
Greetz,
Helen.