Hi all
I have a very simple table
CREATE TABLE "MYUSER"
(
"USERNAME" VARCHAR(8) NOT NULL,
"USERPASSWORD" VARCHAR(8),
"USERLOGGEDIN" "D_BOOLFIELD",
"USERFULLNAME" VARCHAR(25) NOT NULL,
"USERPRIVILEGED" "D_BOOLFIELD"
);
D_BoolField is defined here.
CREATE DOMAIN d_BoolField as CHAR(1) DEFAULT 'N' CHECK (VALUE IN ('Y',
'N'));
I have a form on which there is a DBGrid. I have a DataSource pointing
to an IBQuery (all default properties - just added a db, transaction and
updateobject) on one side and the DBGrid on the other.
The SQL statement of the Query (on form show, the query is opened) is
Select UserName, UserFullName, UserPrivileged from MyUser.
(UserPassword is changed elsewhere and UserLoggedIn is not implemented
yet).
I display the results in the DBGrid. Now, what I want is to be able to
edit that data and save it back to the database through the DBGrid.
So, what I did was hook up an IBUpdateSQL to the system. I put my three
fields UserName, UserFullName and UserPrivileged as both the Key Fields
and Update Fields. Then I pressed GenerateSQL and it generated the SQL
for me, which is fine - see SQL at bottom of post.
The problem that I am having is that when I update or add a record
(deleting is fine!) I get an error
Project Blah raised Exception Class EIBInterBaseError with message
Dynamic SQL Error
SQL Error Code = -104
Token Unknown - line 2, char -1
from'. Process stopped. User step or run to continue.
This is the message verbatim.
And the record that I have added disappears. However, when I go back
into the database, the record is there updated or added and when I
relaunch the programme, the record appears in the grid.
It appears to be something to do with the refresh SQL, but I'm stumped
at this point. Can anyone help me out with what I'm doing wrong here? It
should be relatively simple - I just want to use the grid to edit my
users - do I have to call commit(); at some stage or is this done for
me?
TIA.
Paul...
SQL....
-------Modify-------
update MyUser
set
USERNAME = :USERNAME,
USERFULLNAME = :USERFULLNAME,
USERPRIVILEGED = :USERPRIVILEGED
where
USERNAME = :OLD_USERNAME and
USERFULLNAME = :OLD_USERFULLNAME and
USERPRIVILEGED = :OLD_USERPRIVILEGED
-------- Insert
insert into MyUser
(USERNAME, USERFULLNAME, USERPRIVILEGED)
values
(:USERNAME, :USERFULLNAME, :USERPRIVILEGED)
---------Delete (works no problem!)
delete from MyUser
where
USERNAME = :OLD_USERNAME and
USERFULLNAME = :OLD_USERFULLNAME and
USERPRIVILEGED = :OLD_USERPRIVILEGED
--------Refresh (think problem is here)
Select
from MyUser
where
USERNAME = :USERNAME and
USERFULLNAME = :USERFULLNAME and
USERPRIVILEGED = :USERPRIVILEGED
--
plinehan__AT__yahoo__DOT__com
C++ Builder 5 SP1, Interbase 6.0.1.6 IBX 5.04