-
Content Count
69 -
Joined
-
Last visited
Posts posted by Nathan Wild
-
-
This can not possibly be as complicated as it seems... I want to set an environment variable from within my application that persists after it terminates. I have tried using SetEnvironmentVariable() and then SendMessage() to broadcast the change, to no avail... I found an old post with the following function which seems like it SHOULD do what I want - but no matter what my environment is not touched.
function SetGlobalEnvironment(const Name, Value: string; const User: Boolean = True): Boolean; resourcestring REG_MACHINE_LOCATION = 'System\CurrentControlSet\Control\Session Manager\Environment'; REG_USER_LOCATION = 'Environment'; begin with TRegistry.Create do try if User then { User Environment Variable } Result := OpenKey(REG_USER_LOCATION, True) else { System Environment Variable } begin RootKey := HKEY_LOCAL_MACHINE; Result := OpenKey(REG_MACHINE_LOCATION, True); end; if Result then begin WriteString(Name, Value); { Write Registry for Global Environment } { Update Current Process Environment Variable } SetEnvironmentVariable(PChar(Name), PChar(Value)); { Send Message To All Top Window for Refresh } SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, Integer(PChar('Environment'))); end; finally Free; end; end;
Any help appreciated!
-
In the RadStudio design-time object inspector some properties of some components show up highlighted, for example LiveBindings, CustomHint, PopupMenu, etc. Is there a way to define which properties show up highlighted? I don't much care about LiveBindings or CustomHint's, but I would REALLY like things like Name and Caption that I use ALL THE TIME to be easier to find in the list. I couldn't find anywhere in the OI configuration to change this.
Any guidance much appreciated 🙂
-
Good grief... It never even occurred to me to check and see if TDBNavigator had a StyleElement property... It is missing from the design-time inspector, so I just assumed it did not...
Setting DBNavigator.StyleElements := [seFont,seBorder] had the desired effect. Thanks!
-
I am using a DBNavigator control in one of my applications and for some reason, When I place it on the form it looks fine, but as soon as I connect a datasource to it, all the buttons lose their colour. NOTE: I don't mean they are greyed-out / inactive. I mean where they used to show blue glyphs for the first, previous, next and last buttons, they now show grey ones. They work normally, and grey-out as they should depending on the state of the underlying dataset, but the difference between an enabled button and a disabled on is very hard to see without the colour!
See the attached screen shot. The control on the right was just dropped onto the form, but does not have its datasource property populated. The one on the left is identical, except that it is connected to a TDataSource.
This is definitely the result of a VCL theme thing, but I can't find any properties that allow me to tell this control to ignore the theme (i.e. the standard "StyleElements" property)
Any guidance appreciated!
-
1 hour ago, Ruslan said:Usualy I use "returning" to get the value of new autoincremented field (Firebird).
What do you mean by "returning"?
-
Sorry... I am using Pervasive.
-
I am trying to append records to a pair of tables in a master/detail relationship. The master dataset is a writable FDQuery with an AutoInc key field. When I post to this dataset the autoinc field has a value of -1. I want to go on and write out detail records, but nothing I've tried will give me the actual value for autoinc field in the newly posted master dataset.
I am not able to call FDQuery.Refesh() as it gives me a "SQLBind Parameter has not been called for parameter" error (I've posted about this before and apparently it is a known bug).
FDQuery.RefreshRecord() gives me an error "[FireDAC][DApt]-400. Fetch command fetched [0] instead of [1] record. Possible reasons: update table does not have PK or row identifier, record has been changed/deleted by another user"
As my master dataset is sorted by the autoinc key field, I was able to solve the issue by calling FDQuery.First() and FDQuery.Last(), but this feels wrong, so I thought I would check in and see if anyone had a suggestion for how this *SHOULD* be done?
Thanks in advance...
-
Oh yes, of course... I was just hoping that there was a way to do this somewhat more automatically...
-
I am working with a table that has a large number of fields which are ALL set up as NOT NULL. 90% of these are unused, but need to be populated when inserting new records. Is there an easy / automatic was to tell FD to automatically populate '' and 0 values as appropriate for data type when inserting new records?
-
Lovely... but where does that leave those of us who only have 10.1? 😞
-
So what is the best approach to do this? My end result is that I want to allow the end user to input a key value and then pass that to a a query as a parameter. This works perfectly the first time, but when I close the query, set a new parameter value and then re-open the query, I get this "SQLBindParameter has not been called for Parameter #2" error. Sure;y clearing and re-setting the entire SQL statement is not required?
-
Is there an easy way to see EXACTLY what query FireDAC is passing through to my database server? After it does all the parameter substitutions, and automatic jiggerey pokery? I've had a few weird errors and I think being able to see this would be very helpful.
-
That made my day 🙂
-
Another vote for CodeSite. I've been using a simple collection of functions that wrap it's behavior and it is an excellent, maybe even essential, tool for client-side debugging!
-
Not sure if this helps, but the TJvAppInstances component in the JEDI VCL collection handles this quite nicely.
-
I will try this! Any idea why it would fail with that error when I call fdquery.Refresh()?
-
I am at a loss to explain this, but it feels like I am missing something obvious so I thought I would try here...
If I have a query that does a simple select * with two parameters it works properly. If I modify the underlying table with another query, and then attempt to call .Refresh() or to activate and deactivate the select query I get a FireDAC ODBC error stating that SQLBindParameter has not been called for parameter #4. Firstly, there are only two parameters. Secondly, I don't ever call SQLBindParameter on anything. If I clear the SQL, and reset it, then reassign the parameters, it works fine?
The exact error message is: [FireDAC][Phys][ODBC][Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine Interface]SQLBindParameter has not been called for parameter #4.
Sample code:
fdquery.Active := FALSE;
fdquery.SQL.Clear();
fdquery.SQL.Add('SELECT * FROM MyTable WHERE Key1=:KEY1 AND Key2=:KEY2;');
fdquery.ParamByName('KEY1').AsString = 'value1';
fdquery.ParamByName('KEY2').AsString = 'value2';
fdquery.Active := TRUE;
// This works fine.
If I then execute an "INSERT INTO MyTable" query which generates data in [MyTable], and attempt to refresh the original query. I get the above error. If I set Active := FALSE and then back to TRUE again, I get that error.
The only thing that seems to work is to clear and re-add the SQL, reassign the parameters, and then reactivate it.
Questions:
1) Why is this error occurring at all?
2) Why is it coming up with parameter 4 when there are only two parameters to begin with?!
-
This is something I struggle with a lot and there has to be an easier way?!
I have many projects that have both debug and release configs for win32 and/or win64 targets. Is there a simple way to have the version information THE SAME across all of these? There config options for all builds, all targets, and all configurations, but no matter what I do they all appear to be maintained separately?!
All I want it to be able to set my version info in the Project | Options | Version Info | All Configurations section, and have it JUST WORK...
- 1
TStringGrid maybe problem
in VCL
Posted
Can you post a sample project that exhibits this behaviour?