BIG problem with Locate
-
vallemanden
- Posts: 19
- Joined: Sat 11 Jun 2011 07:44
BIG problem with Locate
Hi
I have BIG problems with locate
Query3.Close;
Query3.SQL.Clear;
Query3.SQL.BeginUpdate;
Query3.SQL.Add('SELECT * from cust');
Query3.SQL.Add('WHERE custnr = ''' + Query1.FieldByName('custnr').AsString + '''');
Query3.SQL.EndUpdate;
Query3.open;
This Works ALL the time, but
Query3.Close;
Query3.SQL.Clear;
Query3.SQL.BeginUpdate;
Query3.SQL.Add('SELECT * from cust');
Query3.SQL.EndUpdate;
Query3.open;
Query3.Locate('custnr', Query1.FieldByName('custnr').AsString, [loPartialKey]);
only works sometimes ?
using delphi2010 on vista32 and MySQL
kind regards
Vallemanden
I have BIG problems with locate
Query3.Close;
Query3.SQL.Clear;
Query3.SQL.BeginUpdate;
Query3.SQL.Add('SELECT * from cust');
Query3.SQL.Add('WHERE custnr = ''' + Query1.FieldByName('custnr').AsString + '''');
Query3.SQL.EndUpdate;
Query3.open;
This Works ALL the time, but
Query3.Close;
Query3.SQL.Clear;
Query3.SQL.BeginUpdate;
Query3.SQL.Add('SELECT * from cust');
Query3.SQL.EndUpdate;
Query3.open;
Query3.Locate('custnr', Query1.FieldByName('custnr').AsString, [loPartialKey]);
only works sometimes ?
using delphi2010 on vista32 and MySQL
kind regards
Vallemanden
-
AndreyZ
Hello,
The point is that the query returns case insensitive values from the server, and the Locate method is case sensitive by default. To avoid the problem, you should use the following code:
The point is that the query returns case insensitive values from the server, and the Locate method is case sensitive by default. To avoid the problem, you should use the following code:
Code: Select all
Query3.Locate('custnr', Query1.FieldByName('custnr').AsString, [loPartialKey, loCaseInsensitive]);-
vallemanden
- Posts: 19
- Joined: Sat 11 Jun 2011 07:44
-
AndreyZ
-
AndreyZ
-
vallemanden
- Posts: 19
- Joined: Sat 11 Jun 2011 07:44
-
AndreyZ
Please specify if the cursor in the TDBGrid component jumps to another position when you call the Locate method. Also, to obtain the same result in the second case, you should use the Filter property instead of the Locate method. Here is an example:
Code: Select all
Query3.Close;
Query3.SQL.Clear;
Query3.SQL.BeginUpdate;
Query3.SQL.Add('SELECT * from cust');
Query3.SQL.EndUpdate;
Query3.Open;
Query3.Filter := 'custnr=' + Query1.FieldByName('custnr').AsString;
Query3.Filtered := True;