Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TForm1.btnImportClick(Sender: TObject);
- var
- FSQL:String;
- begin
- ZQuery1 := TZQuery.Create(nil);
- ZQuery1.Connection := ZConnection1;
- FDoc := TCSVDocument.Create;
- FDoc.Delimiter := Edit4.Text[1];
- FSQL:='';
- if (not FileExists(Edit3.Text)) or (Edit3.Text <> '') then
- FDoc.LoadFromFile(Edit3.Text);
- i := RadioGroup1.ItemIndex;
- Memo2.Lines.Clear;
- if (FDoc.MaxColCount = Memo1.Lines.Count) then
- begin
- ZQuery1.Close;
- for j := 1 to FDoc.RowCount - 1 do //krn ada header
- begin
- //ZQuery1.Close;
- //ZQuery1.SQL.Clear;
- k := imp.ReadInteger(RadioGroup1.Items.Strings[i], Memo1.Lines[0], 0);
- s := QuotedStr(copy(Trim(FDoc.Cells[0, j]), 0, k));
- for m := 1 to Memo1.Lines.Count - 1 do
- begin
- l := imp.ReadInteger(RadioGroup1.Items.Strings[i], Memo1.Lines[m], 0);
- s += ',' + QuotedStr(copy(Trim(FDoc.Cells[m, j]), 0, l));
- end;
- FSQL:= FSQL + 'EXECUTE PROCEDURE '+dbi.ReadString('StoredProcedure', RadioGroup1.Items.Strings[i], 'ErrorSP')+ '(' + s + ','+QuotedStr(dbi.ReadString('System', 'LOGIN', 'ErrorLogin'))+ '); ';
- lblImportLoading.Caption := 'Processing : ' + IntToStr(trunc(j / (FDoc.RowCount - 1) * 100)) + ' %';
- lblImportLoading.Update;
- end;
- try
- ZQuery1.SQL.Clear;
- ZQuery1.SQL.Text:= trim(FSQL);
- ZQuery1.ExecSQL;
- ZQuery1.Free;
- except
- showMessage('Error !');
- end;
- end
- else
- ShowMessage('Column CSV not match with database !');
- end;
Advertisement
Add Comment
Please, Sign In to add comment