Unidbgrid Import Database (turn red fish)

Source: Internet
Author: User
Tags import database

A friend asked how to import Excel into the database, this is my Unigui project code, implement Unidbgrid Import Database function, because with KBMMW, so you see is Unidbgrid import Kbmmwclientquery, Then submit the Clientquery to the database. Share it!
function ImportFromFile (adataset:tkbmmwclientquery; agrid:tunidbgrid; afilename:string): Boolean;
Var

R, c, I:integer;
V:tcellvalue;
Xls:texcelfile;
Begin
Adataset.disablecontrols;
XLS: = Txlsfile.create (False);
Try
Xls. Open (Afilename);
Xls. ActiveSheet: = 1;

for r: = 2to xls. RowCount do
Begin
If not Isblankrow (XLS, R) and then//is not a blank line then fill in
Begin
Adataset.append;
For I: = 0 to Agrid.columns.count-1 do
Begin
c: = Getcolbyname (xls, agrid.columns[i]. Title.caption);
If c <>-1 Then
Begin
Case Adataset.fieldbyname (Agrid.columns[i]. FieldName). Datatypeof
Ftdatetime, Ftdate:
Adataset.fieldbyname (Agrid.columns[i]. FieldName). Asdatetime: =xls. Getcellvalue (R, c). ToDateTime (False);
Else
Adataset.fieldbyname (Agrid.columns[i]. FieldName). Asstring: =xls. Getcellvalue (R, c)
. Tostring.replace (","). Replace (' ' ', ');
End
End
End

Adataset.post;
End
End
Result: =adataset.resolve;

Finally
Adataset.enablecontrols;
Xls. Free;
End
End

Unidbgrid Import Database (turn red fish)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.