Jump to content

Search the Community

Showing results for tags 'adotables'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Delphi Questions and Answers
    • Algorithms, Data Structures and Class Design
    • VCL
    • FMX
    • RTL and Delphi Object Pascal
    • Databases
    • Network, Cloud and Web
    • Windows API
    • Cross-platform
    • Delphi IDE and APIs
    • General Help
    • Delphi Third-Party
  • C++Builder Questions and Answers
    • General Help
  • General Discussions
    • Embarcadero Lounge
    • Tips / Blogs / Tutorials / Videos
    • Job Opportunities / Coder for Hire
    • I made this
  • Software Development
    • Project Planning and -Management
    • Software Testing and Quality Assurance
  • Community
    • Community Management

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Delphi-Version

Found 1 result

  1. PrimeMinister

    Problem with clearing ADO Tables

    Hey guys, so I'm having a problem with my ADO Tables. I have a button in my program that is meant to clear all tables in the database related to the program when clicked but whenever I click it, it gives errors. (no matter how many times I change my code) Could it be a problem with my Data Module or what? (I'm not sure cause my button which saves stuff to the database, works perfectly without a hitch) How could I alleviate this? Code of my data module: const scConnectionString = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%pathtomdb%Racers.mdb;Mode=ReadWrite;Persist Security Info=False;'; var dmRacers: TdmRacers; implementation {%CLASSGROUP 'Vcl.Controls.TControl'} {$R *.dfm} procedure TdmRacers.DataModuleCreate(Sender: TObject); var path:string; begin path:=ExtractFilePath(ParamStr(0)); conToDB.ConnectionString := StringReplace(scConnectionString, '%pathtomdb%', path, []); conToDB.Connected:=True; tbl1660.Active := True; tblXKarts.Active := True; tblTwoPointOne.Active := True; tblMidB.Active := True; tblMidA.Active := True; tblLateModel.Active := True; tblSprints.Active := True; tblV8.Active := True; tblHeavyMetals.Active := True; tblHotrods.Active := True; tblPinkrods.Active := True; tblStockrods.Active := True; tblMinis.Active := True; tblDevelopment.Active := True; end; Code from the form: public { Public declarations } MyCmd:TADOCommand; procedure EmptyTable(tbl:TADOTable;tablename:string); procedure ResetActiveProp(tbl:TADOTable); end; var frmEntry: TfrmEntry; implementation {$R *.dfm} procedure TfrmEntry.ResetActiveProp(tbl: TADOTable); begin tbl.Active := True; end; procedure TfrmEntry.EmptyTable(tbl: TADOTable; tablename: string); var MyCmd: TADOCommand; begin tbl.Active := true; MyCmd.CommandText := 'Delete * from '+tablename; MyCmd.Execute; tbl.Active := false; end; procedure TfrmEntry.bmbClearClick(Sender: TObject); var i:integer; begin cbxGridSelect.ItemIndex:=-1; cbxGridSelect.Text:='Select a class'; edtRacerName.Clear; edtCarNumber.Clear; edtLicenseNum.Clear; i:=MessageDlg('Dialog cleared',mtInformation,[mbOK],0); end; procedure TfrmEntry.bmbClearDBClick(Sender: TObject); var i:integer; begin i:=MessageDlg('Are you sure you want to clear the Racers database? (all current data in the database will be lost.)',mtWarning,[mbOK,mbCancel],0); if i = mrOk then begin //clears entire database with dmRacers do begin EmptyTable(tbl1660,'tbl1660'); EmptyTable(tblXKarts,'tblXKarts'); EmptyTable(tblTwoPointOne,'tblTwoPointOnes'); EmptyTable(tblMidB,'tblMidB'); EmptyTable(tblMidA,'tblMidA'); EmptyTable(tblLateModel,'tblLateModels'); EmptyTable(tblSprints,'tblSprints'); EmptyTable(tblV8,'tblV8'); EmptyTable(tblHeavyMetals,'tblHeavyMetals'); EmptyTable(tblHotrods,'tblHotrods'); EmptyTable(tblPinkrods,'tblPinkrods'); EmptyTable(tblStockrods,'tblStockrods'); EmptyTable(tblMinis,'tblMinis'); EmptyTable(tblDevelopment,'tblDevelopment'); i:=MessageDlg('Database successfully cleared',mtInformation,[mbOk],0); //resets active property of tables ResetActiveProp(tbl1660); ResetActiveProp(tblXKarts); ResetActiveProp(tblTwoPointOne); ResetActiveProp(tblMidB); ResetActiveProp(tblMidA); ResetActiveProp(tblLateModel); ResetActiveProp(tblSprints); ResetActiveProp(tblV8); ResetActiveProp(tblHeavyMetals); ResetActiveProp(tblHotrods); ResetActiveProp(tblPinkrods); ResetActiveProp(tblStockrods); ResetActiveProp(tblMinis); ResetActiveProp(tblDevelopment); end; end else begin i:=MessageDlg('Clear aborted',mtInformation,[mbOk],0); end; end; Example of errors: Thanks in advance for the help! Kind Regards PrimeMinister
×