Jump to content

PenelopeSkye

Members
  • Content Count

    69
  • Joined

  • Last visited

Everything posted by PenelopeSkye

  1. PenelopeSkye

    Query result to dynamic array

    I need to loop through a dynamic array which is populated by the result of a query. I have gotten as far as what you see below, but I keep getting an error Incompatible types: 'Char' and 'Variant' at the end of the following line Result := q_InsValuePackLinks2.Fields[i].Value; I have to admit that I changed a lot of this messing around to the point where I don't know what other parts are wrong, so I thought I'd ask for help! How do I create a dynamic array from q result set? Thanks! procedure TfDesignMaster.btnVP_PostClick(Sender: TObject); var b: array of string; Begin var i,j,numberOfFields: integer; var PresentationID,designid,master_pres,result,presentations:string; with dm do begin master_pres :=q_GetStockNumFromValuePackLinks.FieldByName('master_presentation').AsString; q_InsValuePackLinks2.SQL.Add('select presentation from presentation_master where master_presentation = '+master_pres); q_InsValuePackLinks2.Open; presentations := q_InsValuePackLinks2.Fields.ToString; SetLength(Result,i); for i := 0 to q_InsValuePackLinks2.Fields.Count - 1 do Result[i] := q_InsValuePackLinks2.Fields[i].Value; end; end;
  2. PenelopeSkye

    Query result to dynamic array

    Hi James, our company has paid to have our code converted to c#, so I won't be posting here anymore. I just wanted to thank you for all your help and support. If there is any feedback I can leave anywhere please let me know, but otherwise I am taking it all as a big personal favor!!!
  3. PenelopeSkye

    Query result to dynamic array

    I just got back!! Since I don't understand what you are talking about I can't weigh in, but I am very very happy to say that the code works as expected! 🙂 Thank you both for weighing in!!!
  4. PenelopeSkye

    Query result to dynamic array

    Duuuude! You are a genius!!! Thank you!!!
  5. PenelopeSkye

    Query result to dynamic array

    I tried looping through the dataset and comparing it to the value but the UI behaved very oddly, Sorry, I am not making it easy for you to help, I should probably go home and come back when I feel better!
  6. PenelopeSkye

    Query result to dynamic array

    I am not using it for the memo box. I am clicking on a field with some text. I need to compare the value from that field to a list of values from the database. Wouldn't that call for a dynamic array? Thank you!
  7. PenelopeSkye

    Query result to dynamic array

    type TMyRecToStoreSomeValues2 = record ValInt: integer; ValString: string; ValDate: TDate; // etc... end; TMyValuesInArray = TArray<TMyRecToStoreSomeValues2>; function HelloWorld: TMyValuesInArray; var LMyValue : TMyRecToStoreSomeValues2; LMyValues: TMyValuesInArray; begin LMyValues := [ dm.q_GetStockNumFromValuePackLinks.SQL.Text := 'SELECT art_status FROM [AdiMS2].[dbo].[art_status]'; // // ... // result := LMyValues; end;
  8. PenelopeSkye

    Query result to dynamic array

    I am able to loop through the result set from the query! Thank you both so much!!!
  9. PenelopeSkye

    Query result to dynamic array

    Ah! Got it! Thanks!
  10. PenelopeSkye

    Query result to dynamic array

    Thank you both. I get the master presentation from one table using FieldByName. I use that master presentation to get anywhere from 1 to 8 presentations from a second table. Then I need to loop through the dynamic list of presentations and update the row in the second table. How would I get a dataset with this information without using a query?
  11. PenelopeSkye

    Query result to dynamic array

    Thanks James!!! Unfortunately I haven't successfully gotten the query results into the dynamic array. Did you explain how above and I'm so ignorant I didn't see it? That is entirely possible!!!!!
  12. PenelopeSkye

    Find all mentions of the database

    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!
  13. PenelopeSkye

    Must have multiple var sections

    Unless I want to have a lot of undeclared identifiers I have to have multiple var sections, see below. That is so wrong! Also, this array declaration doesn't work under any circumstances even though I lifted it from another unit in the project and made sure it has the same uses list. x: array[0..9] of variant; The procedure in the other unit was not a (Sender: TObject) procedure (sorry for my ignorance of what to call that). What am I doing wrong? The list below has no errors when I put in all the var sections. procedure TfDesignMaster.PopulatePdlNotesWithValuePack(Sender: TObject); begin var stocknummm,value,value1,value2,keyfields, fieldname: string; var F: TField; var i: integer; var lresult: boolean; var fn:=tstringlist.create; var sl:=tstringlist.create;
  14. PenelopeSkye

    Must have multiple var sections

    Doh! It should have been obvious that that button is what brackets code! Thank you! I am going to start studying the code you gave my above until I understand it, thanks again James!
  15. PenelopeSkye

    Must have multiple var sections

    Hi James, I hope you will see this, I will wait a bit then post is in a new topic. I have a table with the following fields. It was not my design choice but I was overruled. I needed to search every pack_component field in every row for a specific value, so I chose union to bring that about. You gave me most of the code I used to create this procedure which finds the value and its' position and display it in a memo box. The code works perfectly but every now and then I get the attached error. Can you tell me why since the code works? Thank you! [vp_id] ,[Presentation] ,[Design_id] ,[Stock_pack] ,[Order1],[Pack_component1],[Qty1] ,[Order2],[Pack_component2],[Qty2] ,[Order3],[Pack_component3],[Qty3] ,[Order4],[Pack_component4],[Qty4] ,[Order5],[Pack_component5],[Qty5] ,[Order6],[Pack_component6],[Qty6] ,[Order7],[Pack_component7],[Qty7] ,[Order8],[Pack_component8],[Qty8] ,[Order9],[Pack_component9],[Qty9] ,[Order10],[Pack_component10],[Qty10] ,[Order11],[Pack_component11],[Qty11] ,[Order12],[Pack_component12],[Qty12] procedure TfDesignMaster.PopulatePdlNotesWithValuePack2(Sender: TObject); begin //var designid: string; var stocknummm,LText1,LText2,StockFromVP: string; var F: TField; stocknummm := dm.tb_design_master.fieldbyname('jmc_stock_num').asstring; StockFromVP := dm.tblValuePackLinks.fieldByName('Stock_pack').asString; Panel35.Visible :=false; Memo1.Clear; //ShowMessage(stocknummm); with dm do begin q_GetStockNumFromValuePackLinks.SQL.Clear; q_GetStockNumFromValuePackLinks.SQL.Add('select Stock_pack,stockOrder = 1 from ValuePackLinks where Pack_component1 = ' +stocknummm ) ; q_GetStockNumFromValuePackLinks.SQL.Add('union' ) ; q_GetStockNumFromValuePackLinks.SQL.Add('select Stock_pack,stockOrder = 2 from ValuePackLinks where Pack_component2 = ' +stocknummm ) ; q_GetStockNumFromValuePackLinks.SQL.Add('union ' ) ; q_GetStockNumFromValuePackLinks.SQL.Add('select Stock_pack,stockOrder = 3 from ValuePackLinks where Pack_component3 = ' +stocknummm ) ; q_GetStockNumFromValuePackLinks.SQL.Add('union ' ) ; q_GetStockNumFromValuePackLinks.SQL.Add('select Stock_pack,stockOrder = 4 from ValuePackLinks where Pack_component4 = ' +stocknummm ) ; q_GetStockNumFromValuePackLinks.SQL.Add('union ' ) ; q_GetStockNumFromValuePackLinks.SQL.Add('select Stock_pack,stockOrder = 5 from ValuePackLinks where Pack_component5 = ' +stocknummm ) ; q_GetStockNumFromValuePackLinks.SQL.Add('union' ) ; q_GetStockNumFromValuePackLinks.SQL.Add('select Stock_pack,stockOrder = 6 from ValuePackLinks where Pack_component6 = ' +stocknummm ) ; q_GetStockNumFromValuePackLinks.SQL.Add('union' ) ; q_GetStockNumFromValuePackLinks.SQL.Add('select Stock_pack,stockOrder = 7 from ValuePackLinks where Pack_component7 = ' +stocknummm ) ; q_GetStockNumFromValuePackLinks.SQL.Add('union' ) ; q_GetStockNumFromValuePackLinks.SQL.Add('select Stock_pack,stockOrder = 8 from ValuePackLinks where Pack_component8 = ' +stocknummm ) ; q_GetStockNumFromValuePackLinks.SQL.Add('union' ) ; q_GetStockNumFromValuePackLinks.SQL.Add('select Stock_pack,stockOrder = 9 from ValuePackLinks where Pack_component9 = ' +stocknummm ) ; q_GetStockNumFromValuePackLinks.SQL.Add('union' ) ; q_GetStockNumFromValuePackLinks.SQL.Add('select Stock_pack,stockOrder = 10 from ValuePackLinks where Pack_component10 = ' +stocknummm ) ; q_GetStockNumFromValuePackLinks.SQL.Add('union' ) ; q_GetStockNumFromValuePackLinks.SQL.Add('select Stock_pack,stockOrder = 11 from ValuePackLinks where Pack_component11 = ' +stocknummm ) ; q_GetStockNumFromValuePackLinks.SQL.Add('union' ) ; q_GetStockNumFromValuePackLinks.SQL.Add('select Stock_pack,stockOrder = 12 from ValuePackLinks where Pack_component12 = ' +stocknummm ) ; //ShowMessage( q_GetStockNumFromValuePackLinks.SQL.Text) ; q_GetStockNumFromValuePackLinks.Open; while not q_GetStockNumFromValuePackLinks.EOF do begin for F in q_GetStockNumFromValuePackLinks.Fields do begin LText1 := ''; // for var i: integer := 0 to (q_GetStockNumFromValuePackLinks.Fields.Count - 1) do // field name + field value LText1 := q_GetStockNumFromValuePackLinks.Fields[0].Value; LText2 := q_GetStockNumFromValuePackLinks.Fields[1].Value; //ShowMessage(LText1); dm.q_GetStockNumFromValuePackLinks.Next; // to avoid "infinity looping" and catch next values... end; //ShowMessage(LText1); if q_GetStockNumFromValuePackLinks.Fields[0].Value <> '' then Panel35.Visible :=true else Panel35.Visible :=false; q_GetStockNumFromValuePackLinks.Next; end; Memo1.Lines.Add('Bag '+stocknummm+' is in Value Pack ('+LText1+') in Position (' +LText2+')' ); q_GetStockNumFromValuePackLinks.Close; end; end;
  16. PenelopeSkye

    Refresh dbedit after insert

    Long story short: How can I refresh a dbedit box with data from a table I have just inserted data into? Long story long: My sql table and UI has fields for PresentationID, DesignID, StockID plus 5 other initially blank fields. With no input from the user I populate the PresentationID, DesignID, StockID fields in the database using values gotten from elsewhere in the application, the 5 fields are populated with null because they are not included in the insert (see code below). If I did include them they would be null anyway since I don't enter data into them until after the row is inserted with the 3 values. After I insert values into the database using the code below I am able to enter text in the other 5 fields or update the 3 fields but when I click on another tab in the application, and leave the tab I am on, the code written elsewhere that posts the data kicks in and attempts to update the database with the values any of the 8 fields. At that point I get the following Cannot insert the value NULL into column 'Presentation', table 'AdiMS2.dbo.ValuePackLinks'; column does not allow nulls. INSERT fails. because the application doesn't recognize the values just inserted for PresentationID, DesignID, StockID. If I leave the app and come back in the 3 fields are populated with data and the post works just fine with values from the 8 fields. How can I refresh a dbedit box with data from a table I have just inserted data into so that I can immediately start editing and not have to leave the app? Does that make sense? Thank you! PresentationID := dm.tb_dm_presentation_design_links.fieldbyname('presentation').asstring; DesignID := dm.tb_design_master.fieldbyname('design_id').asstring; StockID := dm.tb_design_master.fieldbyname('jmc_stock_num').asstring; q_InsValuePackLinks.SQL.Add ('insert into ValuePackLinks '); q_InsValuePackLinks.SQL.Add ('(Presentation,Design_id,Stock_pack)'); q_InsValuePackLinks.SQL.Add ('VALUES('+Quotedstr(PresentationID)+','+Quotedstr(DesignID)+','+Quotedstr(StockID)+')'); q_InsValuePackLinks.ExecSQL ;
  17. PenelopeSkye

    Refresh dbedit after insert

    LOL!!! Will do!
  18. PenelopeSkye

    Refresh dbedit after insert

    I was working with Master\Detail but I was seriously out of time when someone pointed out that there is already a function the refreshes the data used by the app. I used that function and it works perfectly 🤦‍♀️ I am still going to work with Master\Detail in the future cause now I know about it I want to figure it out! Thanks James!
  19. PenelopeSkye

    Refresh dbedit after insert

    I am still getting errors but I will start up again Monday! I will solve it!
  20. PenelopeSkye

    Refresh dbedit after insert

    I will go back to studying the master detail thingee! Thanks Mr. Bond!
  21. PenelopeSkye

    Refresh dbedit after insert

    Ooh! I will try closing and opening first!
  22. PenelopeSkye

    Refresh dbedit after insert

    All 5 fields are set to accept null values, only the 3 are not null and I always have that data. They are indeed being inserted as new rows into another table, not the tables that the 3 fields are originally populated from I am going to start investigating the master detail relationship! Thanks James!
  23. PenelopeSkye

    Must have multiple var sections

    LOL!!!!!! Well thank you James!!!!!
  24. PenelopeSkye

    Must have multiple var sections

    I spoke too soon! It works! It feels too impersonal to thank your handle, so I shall call you Victor. Thank you so much Victor!!!
  25. PenelopeSkye

    Must have multiple var sections

    I have started working with your code, thank you so much for adding comments!!! I am having some issues that I am working on, I will post back here if I can't solve them if you wouldn't mind. Thank you!
×