Any way to extract values from TDBGrid? - c++builder

if(TPoints->Filter == String(Lat1) + String(" < Latitude AND ")+
String("Latitude< ")+ String(Lat2) + String(" AND ")+
String(Lon2) + String("< Longitude AND ")+
String("Longitude < ") + String(Lon2));
else{
ShowMessage("Invalid Boundries");
}
First time using data access and control components.
TPoints is a TADOTable, results are listed in a TDBGrid. If possible I need to do more than just showing the filtered results (filtering code above) from database. How to go to a specific row or maybe cell and play with it?

To move to a specific record, you have to set the RecNo property of TADOTable.
In a database, moving to a specific field of a record (AKA a cell) does not mean much, unless you want to edit the content of it. The Edit() method of TADOTable can put a record into edit mode, but I'm not sure how you can choose a cell programmatically. It also depends on your design. Normally, the user can start the edit mode by double-clicking on a cell, which takes care of everything automatically. But, if you want to change the data without the user typing it, a TADOQuery and SQL statement is a much better choice.
Be more specific about what you want to happen on the screen and the user's interaction. That way, we can help you better.
By the way, you don't extract data from the grid itself, you extract it from a DataSet (TADOQuery or TADOTable) that the grid is attached to.

Related

Adding values to custom (DataExt) fields when adding line items to existing quickbooks Estimates

I'm trying to find the best way to add a value to a DataExt field when adding a line item to an existing Quickbooks transaction (in this particular case an Estimate). I can add a value for a DataExt field when adding line items to a NEW Estimate since the IEstimateLineAdd object includes IDataListExt. However, IEstimateLineMod does not appear to include IDataExtList. There also does not appear to be support for defMacro/useMacro either. I would like to avoid having to go back and dig out the line items (using some combination of their data values) from the Response data, get the TxnLineIDs for each one and then use DataExMod to add the custom data field after the fact.
However, IEstimateLineMod does not appear to include IDataExtList.
Correct.
There also does not appear to be support for defMacro/useMacro either.
Also correct.
I would like to avoid having to go back and dig out the line items (using some combination of their data values) from the Response data, get the TxnLineIDs for each one and then use DataExMod to add the custom data field after the fact.
That is exactly what you need to do.

how to track the social media icons using DTM (Dynamic tag manager)

I have the below code in my web site.
I want to track each anchor tag using DTM. I know how to track single element. Since here we have a bunch of different elements, can anyone help how to track them using DTM? I don't want to create separate rule for each element. In a single rule how can we track these elements.
Here is an example of what you can do.
For Element Tag or Selector put "a.at-share-btn" (no quotes). This will target all the relevant links first. We can look for this too in the next step, but "pre-qualifying" it with this will improve performance so that the rule is not evaluated against every single a click.
Then, under Rule Conditions, add a Criteria of type Data > Custom.
In the Custom box, add the following:
var shareType = this.getAttribute('class').match(/\bat-svc-([a-z_-]+)/i);
if (shareType&&shareType[1]) {
_satellite.setVar('shareType',shareType[1]);
return true;
}
return false;
This code looks for the class (e.g. "at-svc-facebook") and puts the last part of it (e.g. "facebook") into a data element named shareType.
Then, you can reference it using %shareType% in any of the DTM fields. Note: because this data element is made on-the-fly, it will not show up in the auto-complete when you type it out in a field.
Alternatively, in custom code boxes (e.g. if you are needing to reference it in a javascript/3rd party tag box), you can use _satellite.getVar('shareType')

DataSnap using AutoInc key and refresh current record only after insert

I've not been able to find an answer on this anywhere. Using Delphi XE7 with TClientDataSet, DataSnap & SQL Server. I need to insert a record, apply updates and then refresh that record so I can get the Id and assign it to my object. Seems pretty basic requirement, but on the contrary it is proving to be a royal pain.
I've found the obvious stuff on EDN, SO and Dr Bob:
http://edn.embarcadero.com/article/20847
DataSnap and the autoinc field
http://www.drbob42.com/examines/examinC0.htm
However these seem to focus on a "Refresh" of the TClientDataSet to re-fetches the entire table/query. Whilst this does actually resolve the Id field itself (good!), it also moves the cursor off the current record which was just inserted and so I'm not able to get the Id and assign it to my object. Also, for performance over HTTP I don't really want to refetch the entire table every time a record is inserted, if there's 10,000 records this will consume too much bandwidth and be ridiculously slow!
Consider the following code:
function TRepository<I>.Insert(const AEntity: I): I;
begin
FDataSet.DisableControls;
try
FDataSet.Insert;
AssignEntityToDataSet(AEntity); // SET'S ALL THE RELEVANT FIELDS
FDataSet.Post;
FDataSet.ApplyUpdates(-1);
FDataSet.Refresh; // <--- I tried RefreshRecord here but it cannot resolve the record
AEntity.Id := FDataSet.FieldByName('Id').AsInteger; // <----- THIS NOW POINTS TO WRONG ROW
finally
FDataSet.EnableControls;
end;
end;
Does anyone know how to achieve this? I need to be able to refresh and stay on the current record otherwise I do not know the Id of the record just created and the GUI cannot stay focused on the current record.
Hopefully something obvious I'm missing.
Cheers.
Rick.
Assuming you can get hands on the new ID inside the AfterUpdateRecord event of your DataProvider, your event handler then may look like this (the current record of DeltaDS is the one just inserted into SourceDS):
if (UpdateKind = ukInsert) then begin
DeltaDS.FindField('Id').NewValue := <TheNewID>;
end;
Make sure to have the poPropogateChanges option set in the provider. This will transfer the changed Id field back to the ClientDataSet.
Now you can get rid of the FDataSet.Refresh call.
SQL Server does allow you to get the last identity it generated in several ways - there's no need to "refresh" the record/query which means re-issuing a SELECT and can generate undesiderable side-effects. You can use SELECT SCOPE_IDENTITY() or use an OUTPUT clause. If the Delphi database driver supports it, TField.AutogenerateValue should accomplish that task automatically (see http://docwiki.embarcadero.com/Libraries/XE7/en/Data.DB.TField.AutoGenerateValue)
Otherwise you have to put that new data into your delta (see Raabe answer - this has to be done on the datasnap server which actually talks to the database) after reading it, so it's sent back to the client. You also need to set properly and TField.ProviderFlags to ensure data are applied correctly (see http://docwiki.embarcadero.com/RADStudio/XE7/en/Influencing_How_Updates_Are_Applied), usually you don't want those field appear in an UPDATE.

Delphi - Passing data from a TQuery to Quickreport component (QRDBText)

This may be a newbie question, but I was unable to solve this problem.
I have a TQuery component (Query1) wich returns me a dataset from a database.
I would like to pass the records in it to a QuickReport QRDBText component - with no success so far.
I am creating the Query1 in run-time, and then an event (button press) would come up with the Quickreport. I got this far with it:
QReport.DataSet:=Query1;
QRDBText1.DataSet:=Query1;
QRDBText1.Datafield:='Vnev'; //first field in query
QRDBText2.DataSet:=Query1;
QRDBText2.Datafield:='Knev'; //second field in query
QRDBText3.DataSet:=Query1;
QRDBText3.Datafield:='Idcard'; //third field in query
But this shows me the big grey nothing.
If I operate with a sample database and place a TTable on the QuickReport, and set up the connections via the Object Inspector, it works. But again: I need to display data from my Query.
Any help would come handy! Thanks
The QRdetailband should set to true and fill the QRdbtext on it.

Wix: ListBox value limitation

Value field in ListBox table has String[64] type. Is there posible to expand this 64-characters limitation? I need to store some directory pathes there.
It's probably (never tried) possible in WiX to override the default schema of he ListBox table. I know in InstallShield I just go to the direct editor and adjust it. WiX has a template schema that is used to build the MSI and you might be able to use the Table element to redefine it. Or it might just give you an error message saying you are defining a well known table.
However, I'm not sure if there would be any side effects in the ListBox control if you exceed 64 char. I don't see anything in the MSI SDK saying what's allowed so I guess your milage may vary.
Here's a trick that you might like though. It's called the evil twin dialog trick. See, in MSI there's a bug that UI elements don't refresh very well and this trick works around it. Consider this:
Dialog1 with ListBox associated to property TESTPROP and Items One value 1 and Two value 2.
Textlabel that displayes [TESTPROP].
When start the dialog the text label is empty after clicking a row in the listbox. Click back and next and suddenly it has the expected text of 1 and 2.
Now create a clone of this dialog ( Dialog2 ) and put a control event on the Listbox of dialog1 that says NewDialog Dialog2 condition=1 and put a control event on the Listbox of dialog2 that says NewDialog Dialog1 condition = 1
Now when you run it the screen refreshes ( although with a big of an ugly flicker ) See it looks like it's the same dialog only it's really the evil twin dialog that's being transitioned to so that the data refreshes correctly.
Now for extra credit use your custom actions to do something like this
ListBox Item 1 Text C:\Pro...Foo\Bob value LISTBOXDIRPROP1
ListBox Item 2 Text C:\Pro...Foo\Ed value LISTBOXDIRPROP2
Property LISTBOXDIRPROP1 = C:\Program Files\Foo\Bob
Property LISTBOXDIRPROP2 = C:\Program Files\Foo\Ed
Then set your TextLabel to display [[TESTPROP]]. This tells it to get deference the value of the value of the property. In other words, TESTPRO = LISTBOXDIRPROP1 = C:\Proggram Files\Foo\Bob
This trick would allow you to display a line that fits the 64 char constraint yet gives additional information when the user selects it.

Resources