Search the Community
Showing results for tags 'database'.
Found 15 results
-
Connecting Delphi 10.1 App to Azure Cosmos DB for MongoDB
Robert_Ha posted a topic in Network, Cloud and Web
Hello everyone, I'm new to the Cloud topic and how to connect my Delphi 10.1 dektop application to the "Azure Cosmos DB for MongoDB" Cloud-storage (NoSQL?). The MongoDB is set up by someone else and I have to connect to it, send and retrieve data in json format. In my understanding, the cloud needs a REST-API as interface to which I connect with my Delphi-App (because of security). I don't really understand with which component or class of Delphi 10.1 I can communicate with it. Can I use the "AzureConnectionInfo" and "AzureAPI" for all tasks? Do I need to use TRESTClient/Request/Response? Is the use of FireDAC reasonable for NoSQL? I'm lost here, because the documentation of Embarcadero is really short on that. Thank you very much in advance! Robert -
Specs: Delphi XE7, VCL, Windows 7 - DBGrid and added a checkbox column to it I've searched around the web for ideas and howtos. Well, I came across a few resources and met with some success. I've even added/included an additional feature to allow user (that's me) to add edit checkbox via keyboard space. It works. https://www.thoughtco.com/place-a-checkbox-into-dbgrid-4077440 https://stackoverflow.com/questions/9019819/checkbox-in-a-dbgrid I copy/pasted the code from the second link, then I added the code to allow checkbox column updates via the keyboard space (spacebar) from the first link, and ported to the code from the second link. I hope that made sense. <-- My first "codesnippet" contribution to the community !! However, there appears to be one small problem. The checkbox column is showing the text: True or False, whichever is set to., and you can see the outline of the column box when that field is entered into. Complete source code is included below. Just add a (dbgrid, button, tfdmemtable, and datasource) to your forum, and be sure to double-click the event(s) for each of these Procedures in order to activate them. You can click the ch field or hit the spacebar to update the checkbox field. Is there any way I can resolve this artifact? unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.SQLite, FireDAC.Phys.SQLiteDef, FireDAC.Stan.ExprFuncs, Data.DB, FireDAC.Comp.Client, Vcl.Grids, Vcl.DBGrids, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.DataSet, FireDAC.VCLUI.Wait, FireDAC.Comp.UI; type TForm1 = class(TForm) Panel1: TPanel; Button1: TButton; eb1: TEdit; conn: TFDConnection; btnInsert: TButton; DBGrid1: TDBGrid; ds: TDataSource; mytable: TFDMemTable; procedure Button1Click(Sender: TObject); procedure btnInsertClick(Sender: TObject); procedure dbgrid1CellClick(Column: TColumn); procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); procedure DBGrid1ColEnter(Sender: TObject); procedure DBGrid1ColExit(Sender: TObject); procedure DBGrid1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormCreate(Sender: TObject); procedure DBGrid1KeyPress(Sender: TObject; var Key: Char); private { Private declarations } GridOriginalOptions : TDBGridOptions; public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.btnInsertClick(Sender: TObject); begin myTable.FieldDefs.Clear; mytable.FieldDefs.Add('ch', ftBoolean, 0,false); // the checkbox 'ch' a boolean myTable.FieldDefs.Add('id', ftAutoInc, 0,False); myTable.FieldDefs.Add('name',ftString, 20,False); myTable.CreateDataSet; myTable.Append; myTable.FieldByName('name').AsString := 'delphi'; myTable.Post; mytable.Open; end; procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); const CtrlState: array[Boolean] of integer = (DFCS_BUTTONCHECK, DFCS_BUTTONCHECK or DFCS_CHECKED) ; begin if (Column.Field.DataType=ftBoolean) then begin DBGrid1.Canvas.FillRect(Rect) ; if (VarIsNull(Column.Field.Value)) then DrawFrameControl(DBGrid1.Canvas.Handle,Rect, DFC_BUTTON, DFCS_BUTTONCHECK or DFCS_INACTIVE) else DrawFrameControl(DBGrid1.Canvas.Handle,Rect, DFC_BUTTON, CtrlState[Column.Field.AsBoolean]); end; end; procedure TForm1.DBGrid1ColEnter(Sender: TObject); begin if Self.DBGrid1.SelectedField.DataType = ftBoolean then begin Self.GridOriginalOptions := Self.DBGrid1.Options; Self.DBGrid1.Options := Self.DBGrid1.Options - [dgEditing]; end; end; procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if ((Self.DBGrid1.SelectedField.DataType = ftBoolean) and (key = VK_SPACE)) then begin Self.DBGrid1.DataSource.DataSet.Edit; Self.DBGrid1.SelectedField.Value:= not Self.DBGrid1.SelectedField.AsBoolean; Self.DBGrid1.DataSource.DataSet.Post; end; end; // this portion of code snippet is my contribution to the community. I did not see this code anywhere. it does work. procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char); begin if (key = ' ') then begin self.DBGrid1.DataSource.DataSet.Edit; self.DBGrid1.SelectedField.Value := not self.DBGrid1.Fields[0].AsBoolean; self.DBGrid1.DataSource.DataSet.Post; end; end; procedure TForm1.FormCreate(Sender: TObject); begin GridOriginalOptions := DBGrid1.Options end; procedure TForm1.DBGrid1ColExit(Sender: TObject); begin if Self.DBGrid1.SelectedField.DataType = ftBoolean then Self.DBGrid1.Options := Self.GridOriginalOptions; end; procedure TForm1.dbgrid1CellClick(Column: TColumn); begin if (Column.Field.DataType=ftBoolean) then begin Column.Grid.DataSource.DataSet.Edit; Column.Field.Value:= not Column.Field.AsBoolean; Column.Grid.DataSource.DataSet.Post; end; end; end.
- 4 replies
-
- delphi xe7
- vcl
- (and 4 more)
-
Hello everyone, I'm seeking insights on database development practices in Delphi with Firebird. I have two specific questions: When it comes to database development in Delphi, what is the recommended approach: utilizing data-aware components like drag-and-drop fields and linking with TFDQuery for CRUD operations, or segregating CRUD operations into separate units for forms? I'm particularly interested in understanding the balance between ease of use, efficiency and code usability. Any insights or examples you can provide would be greatly appreciated. Often, we encounter situations where we need to fix a bug or implement changes in just one form out of many (over 100 forms) within our system. Currently, we update the complete executable, which includes all VCL forms in one project. What would be the best approach to handle such incremental updates efficiently without impacting all clients? I'm eager to learn about effective strategies in this scenario. Thank you for your valuable input. Warm regards, Noor
-
I created a test database and pointed the connection string to it, and I found 1 other place where the database name is mentioned after searching in all files. Unfortunately although some of the code works to insert into the database, not everything does, and I am thinking that there are other places indicating the database that I am not finding by using the search function. Does anyone know how to find other places where code is pointed to a database or do I need to search through every object? Thanks!
-
My ADO connection doesn’t support Microsoft access database on C++ Builder 10.4 community edition the providers dont include anything that supports: “C\Users\Student\OneDrive\Documents\5010CEN Shoe booking\ShoeBooking.accdb” ‘ACCDB’ could you please help resolve as in tutorials i see a provider that supports ‘ACCDB’ why does my version not have the same provider
-
If you was to create a rhyming dictionary, how would you structure the database?
Al T posted a topic in Databases
Hi, I'm trying to think of the best structure for a offline rhyming dictionary database. I'm willing to make it a open source offline dictionary, but need some ideas on how to best create the dictionary without bogging it down or making it bloated. Thank you in advance!- 8 replies
-
- dictionary
- rhyming
-
(and 2 more)
Tagged with:
-
I am trying to insert into a database. I am using the code below. When I run the code I get the error message also below. It is my understanding that the command text is only if you are using a sql statement which I am not. What am I missing? Thanks! procedure TfDesignMaster.btnAddUserClick(Sender: TObject); var userstring,OldValue: string; begin with dm do begin userstring := CurrentUserName; OldValue := dbedit23.text; dsetAddUser.Open; tbAddUser.Insert; tbAddUser['JM_User'] := userstring; tbAddUser['OldValue'] := DBEdit23.Text; tbAddUser.Post; end; end;
-
I have inherited an app written in Pascal which I have never written before. I am barely competent with c sharp. I am using Embarcadero® Delphi 10.3 I have created my own program that gets data from a database and inserts data, but as far as the uber app goes I cannot figure out how text from edit boxes is being written to the database as soon as it is typed. For example I created a button that populates a edit box (the person I work with is tired of everybody entering a certain string incorrectly). When the user types in text it is automatically saved to the database, but in order for the text that is populated by clicking on the button to be saved the user has to click an edit button on a TBDNavigator, then press the button to populate the box, then press the post button. I have included the code snippet below, I couldn't see any instructions on how to format code. procedure TfDesignMaster.NoUPCButtonClick(Sender: TObject); begin DBEdit85.Text := 'NO UPC ON ITEM'; end; I know there must be a way to open edit and post but I can't find the datasource for it, there are so many associated with the project and I don't know the name of it. Does anyone know of a way to find the datasource that will allow me to add the code to edit and post? This is the only button that does this in the entire app or I would copy the code, and the other edit boxes are not pointing me anywhere. I am sure I am leaving out all sorts of information needed to answer this question, apologies and please let me know what information I can provide! Thanks!
-
Hi all, A generic question. I'm deploying my apps with an embedded SQLite DB. Each time I compile/deploy, that existing on device DB file is overwritten by the default one. It's fine for development. But how do you actually proceed if you want to deploy an update? If a user has the app already with personal data, I don't want her/him to lose that data. Testing whether the DB already exists is not possible since it's deployed each time within the new binary. One way would be to have all the code to check whether the DB exists. If not, programmatically create it and fill it with sample data. If it does, just check its version and apply possible structure upgrades? But it feels like this would embark a lot of code that may not really be useful. How do you guys deploy news versions of your apps without overwriting exists DBs? I especially think about iOS and Android devices. Thanks for any light. Steve
-
Guys, i'm having trouble using TBatchMove in my project. I'm migrating data from a Firebird database to a PostgreSQL database. I thought to retrive the data from de FB database without the primary key fields, because the destination tables in the PG database already have a primary key setted as serial, therefore the DB would create the indexes i needed. However, TBatchMove doesn't seem to work well with implicit values, everytime i try to execute the command, it tries to pull the primary key value from the closest field. When i added mappings to the component... Well, it started to try sending null values to the table. I am getting desperate, any solutions for this problem?
-
- tbatchmove
- firedac
-
(and 4 more)
Tagged with:
-
how to store a video location to database and restore to play it in tMediaPlayer ?
toufik posted a topic in VCL
hello every one ..............how to store a video location to database and restore to play it in tMediaPlayer ? thank you -
good morning every one ^^ how is every one doing )) 1- i have fmx android app that s create sqllite db on create ,what's the location of db on the phone and is it const location ? (does not change for every other phones) 2- what's the proper way to copy it from that location to sd card (backup) ? thanks and take care
-
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
-
Hello all, Getting "ibtogo64.dll not found in the path" when trying to run on any computer that does not have Interbase installed. I have been using Advantage local server and would like to move to iblite for testing and small desktop projects. I created a small test project using the sample data. I copied the compiled project and supporting files, including license file and data to a USB drive. Stopped the Interbase service and ran the project fine. Moved the USB drive to a different computer and got the error as soon as project ran. To make sure the running project was using the local DLL, I moved the USB back to the development computer and removed the DLL. Got the error, pasted back everything fine. What am I missing. Things I checked: Made sure DLL's are in same directory as exe Deployment files all checked except reg_ibtogo.txt using reg_iblite.txt reg_iblite.txt is in the license folder Interbase directory in same directory as exe Project is release version I ran the program from USB on laptop that has Interbase installed and service stopped and worked fine. any help would be appreciated, Gary
-
The following code works perfectly with one task but fails to process one input variable with two tasks, two input variables with three tasks, etc. pipeline := Parallel .Pipeline .Stage( procedure(const input, output: IOmniBlockingCollection) var NewAmt, OldAmt: Currency; aDataObj: TDataObj; aValue: TOmniValue; aDm: TdmRetriever; begin aDm := TdmRetriever.Create(nil); aDm.SetUp(DataPath); aDataObj := TDataObj.Create('', 0, 0); try for aValue in input do // input is a stringlist of AcctNum begin s := aValue.AsString; MySL.Add(s); aDm.qRetrieverNew.SQL.Text := 'SELECT SUM(Amount) AS CurrYrAmt FROM TransBS' + #13 + 'WHERE (dDate <= ' + QuotedStr(ThruDateStr) + ') AND (AcctNum = ' + QuotedStr(s) + ')'; aDm.qRetrieverOld.SQL.Text := 'SELECT SUM(Amount) AS PrevYrAmt FROM TransBS' + #13 + 'WHERE (dDate <= ' + QuotedStr(PrevThruDateStr) + ') AND (AcctNum = ' + QuotedStr(s) + ')'; aDm.qRetrieverNew.Open; aDm.qRetrieverOld.Open; // Everything continues fine with one task; execution continues with first AcctNum // The first AcctNum is not processed below with two tasks // The first and second AcctNum are not processed below with three tasks if not VarIsNull(aDm.qRetrieverNew.FieldByName('CurrYrAmt').AsVariant) then NewAmt := aDm.qRetrieverNew.FieldByName('CurrYrAmt').AsCurrency else NewAmt := 0; if not VarIsNull(aDm.qRetrieverOld.FieldByName('PrevYrAmt').AsVariant) then OldAmt := aDm.qRetrieverOld.FieldByName('PrevYrAmt').AsCurrency else OldAmt := 0; MySL.Add(s + ', ' + CurrToStr(NewAmt) + ', ' + CurrToStr(OldAmt) ); aDataObj.fAcctNum := s; aDataObj.fCurrYr := NewAmt; aDataObj.fPrevYr := OldAmt; if not output.TryAdd(aDataObj) then break; end; aDm.SessionRetriever.CloseDatabase(aDm.dbRetriever); aDm.SessionRetriever.DropConnections; finally aDataObj.Free; aDm.Free; end; end ).NumTasks(aNumTasks) .Stage( The results, as logged to the MySL stringlist, are attached. I have no idea how to fix this. "aDm" is datamodule I create which contains the queries. I have placed the query openingss in a try-except and never received an error. I have placed query.isempty in a while loop since the query for AcctNum 1111 takes about 4 seconds. The answer is probably something simple, but I'm at a loss as to what I am doing wrong. Will appreciate any help. Log.txt
- 9 replies
-
- omnithreadlibrary
- database
-
(and 1 more)
Tagged with: