Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Don't know if TUNIQuery has ExecSql method but this will work with TADOQuery, in my case the ListView.ViewStyle is set to vsReport and it contains 4 cols.</p> <p>I think if you use a StringGrid or a Dbgrid will be much easier to handel </p> <pre><code>procedure TForm1.PostData; const SQLCMD = 'INSERT INTO MYTABLE (NAME, POSITION, SALL, DATE) VALUES '+ '(%s, %s, %s, %s)'; var // IL: TListItem; I, J, ItemsCount, SubItemsCount: integer; LineItem: array of string; begin ItemsCount:= ListView1.Items.Count; for I := 0 to ItemsCount - 1 do // looping thru the items begin SubItemsCount:= ListView1.Items[I].SubItems.count; SetLength(LineItem, SubItemsCount + 1); LineItem[0]:= ListView1.Items[0].Caption; // the first item caption (first col) for J := 0 to SubItemsCount - 1 do // looping thru the subitems of each line LineItem[J+1]:= ListView1.Items[I].SubItems.Strings[J]; // // just to see the sql command // ShowMessage( // Format(SQLCMD, [ QuotedStr(LineItem[0]), // QuotedStr(LineItem[1]), // LineItem[2], //int field no need to quote the parameter // QuotedStr(LineItem[3])] // )); // with TAdoQuery.Create(nil) do try ConnectionString:= 'Your Connection String'; SQL.Text:= Format(SQLCMD, [QuotedStr(LineItem[0]), QuotedStr(LineItem[1]), LineItem[2], //int field no need to quote the parameter QuotedStr(LineItem[3])); ExecSql; // you might handel execsql to know the row was affected, also not sure if unidac have the same method finally Free; end; SetLength(LineItem, 0); end; end; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload