 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Brandon Lilly Guest
|
Posted: Thu Jul 03, 2003 10:43 pm Post subject: Something changes ReadOnly to True |
|
|
This is related to MSG: Not including identity column in an insert.
The identity column has been changed to a TIntegerField inside the
DFM, and its ReadOnly property changed to FALSE, and the Provider
flags = [pfInKey] as follows:
object dsDocImportDIM_Key: TIntegerField
FieldName = 'DIM_Key'
ProviderFlags = [pfInKey]
end
Notice that ReadOnly is not set to TRUE (false is default so doesn't
show in DFM). Yet when I run the application, where I assign
dsDocImportDIM_Key.NewValue equal to the newly inserted identity,
DBClient.TCustomClientDataSet.SetFieldData raises an exception because
SOMEHOW dsDocImportDIM_Key.ReadOnly is now TRUE!?!
How can this happen? Nothing in my code except for the part that sets
the identity value after the record inserts is even aware of this
dataset, much less DIM_Key. I have tried forcing ReadOnly = FALSE in
the DFM, but that does no good.
Ideas?
Brandon
--
"In the beginning the universe was created. This has made a lot of
people very angry, and has been widely regarded as a bad move." -
Douglas Noel Adams (1952-2001)
|
|
| Back to top |
|
 |
Yuval Malisov Guest
|
Posted: Sun Jul 06, 2003 6:10 pm Post subject: Re: Something changes ReadOnly to True |
|
|
I had something similar :
When I used "select * from ... order by ..." I noticed that the entire
dataset became read-only.
In the help files I found (after a long search) that if you use select
and don't order by the original
table's key - your dataset becomes read-only. There is another settng:
Also, if you're using TQuery
or something related - you must set RequestLive to True.
I don't know if that's your case, but I hope this helps....
Yuval.
"Brandon Lilly" <brandon.lilly (AT) nospam_medevolve (DOT) com> wrote
| Quote: | More info...
I inspected the actual instance of the TField object, and its name was
blank, so I am assuming that Delphi is auto-creating the field for
some reason, and KNOWS that it is in actuality a ftAutoInc datatype...
What is causing this and how can I get Delphi to stop it????
This is occuring at some point in the AfterUpdateRecord event of the
TDataSetProvider
Delphi 6.02
Windows XP XP 1
Brandon
--
"In the beginning the universe was created. This has made a lot of
people very angry, and has been widely regarded as a bad move." -
Douglas Noel Adams (1952-2001)
|
|
|
| Back to top |
|
 |
Brandon Lilly Guest
|
Posted: Sun Jul 06, 2003 7:42 pm Post subject: Re: Something changes ReadOnly to True |
|
|
I don't use order by clauses in my queries, preferring to sort on the
client. I am using TADODataSet objects, so I don't think any of the
suggestions will help me here.
Thanks,
Brandon
--
"In the beginning the universe was created. This has made a lot of
people very angry, and has been widely regarded as a bad move." -
Douglas Noel Adams (1952-2001)
|
|
| Back to top |
|
 |
lc Guest
|
Posted: Tue Jul 08, 2003 10:31 am Post subject: Re: Something changes ReadOnly to True |
|
|
On Thu, 3 Jul 2003 17:43:34 -0500, "Brandon Lilly"
<brandon.lilly (AT) nospam_medevolve (DOT) com> wrote:
| Quote: | dsDocImportDIM_Key.NewValue equal to the newly inserted identity,
|
For one, you should not change NewValue directly. NewValue and
OldValue are automatically managed by assigning (or not) Value
property.
| Quote: | DBClient.TCustomClientDataSet.SetFieldData raises an exception because
SOMEHOW dsDocImportDIM_Key.ReadOnly is now TRUE!?!
|
Two thing to check: ClientDataSet.ReadOnly and
DataSetProvider.Options.poReadOnly.
Also, did you create persistent fields on both sides?
lc
|
|
| Back to top |
|
 |
Brandon Lilly Guest
|
Posted: Tue Jul 08, 2003 8:33 pm Post subject: Re: Something changes ReadOnly to True |
|
|
"lc" <lcdata (AT) hotmail (DOT) com> wrote
| Quote: | For one, you should not change NewValue directly. NewValue and
OldValue are automatically managed by assigning (or not) Value
property.
|
According the multi-tier stuff that I have always seen, when changing
a field value from the server that you want to propagate to the client
(after all inserts and updates have already occurred on the server),
you set the NewValue property. We use this in at LEAST 100 other
places in the exact same manor (in fact, they all call the same
centralized function to populate the identity field value).
| Quote: | Two thing to check: ClientDataSet.ReadOnly and
DataSetProvider.Options.poReadOnly.
|
Neither of these are true (client and server).
| Quote: | Also, did you create persistent fields on both sides?
|
Yes.
Brandon
--
"In the beginning the universe was created. This has made a lot of
people very angry, and has been widely regarded as a bad move." -
Douglas Noel Adams (1952-2001)
|
|
| Back to top |
|
 |
lc Guest
|
Posted: Wed Jul 09, 2003 10:50 am Post subject: Re: Something changes ReadOnly to True |
|
|
On Tue, 8 Jul 2003 15:33:07 -0500, "Brandon Lilly"
<brandon.lilly (AT) nospam_medevolve (DOT) com> wrote:
| Quote: | According the multi-tier stuff that I have always seen, when changing
a field value from the server that you want to propagate to the client
(after all inserts and updates have already occurred on the server),
you set the NewValue property. We use this in at LEAST 100 other
places in the exact same manor (in fact, they all call the same
centralized function to populate the identity field value).
|
.... and the fact that you do what you do is on the server side was
really so obvious from your original message.
lc
|
|
| Back to top |
|
 |
lc Guest
|
Posted: Fri Jul 11, 2003 11:25 pm Post subject: Re: Something changes ReadOnly to True |
|
|
On Fri, 11 Jul 2003 11:39:53 -0500, "Brandon Lilly"
<brandon.lilly (AT) nospam_medevolve (DOT) com> wrote:
| Quote: | No need to be a sarcastic ass.
|
Watch your language!!
You did not supply enogh & relevant information in your original
question. The answers were doomed to be insatisfactory. Yet, you
decide to give me a "doh" reply. You deserved *polite* sarcasm.
;c
|
|
| Back to top |
|
 |
Brandon Lilly Guest
|
Posted: Sat Jul 19, 2003 10:00 pm Post subject: Re: Something changes ReadOnly to True |
|
|
"G. Allen Casteran" <allen (AT) nisinc (DOT) com> wrote
| Quote: | Might be a good idea for you to post the DDL for the table(s) in
question as well as the SQL for your SELECT.
|
-- Table DDL
CREATE TABLE dbo.TDocument_Imports (
DIM_Key int IDENTITY (1, 1) NOT NULL ,
DIM_Filename varchar (256) NOT NULL ,
DIM_DocType int NOT NULL ,
DIM_DateImported datetime NOT NULL CONSTRAINT
DF__TDoc_Imported__DIM_DateImported DEFAULT (CURRENT_TIMESTAMP),
DIM_ImportedBy varchar (15) NOT NULL ,
DIM_Object image NOT NULL ,
DIM_Text text NULL ,
CONSTRAINT PK__TDocument_Imports PRIMARY KEY CLUSTERED (DIM_Key) ON
PRIMARY ,
CONSTRAINT FK__TDocument_Imports__DIM_DocType FOREIGN KEY
(DIM_DocType) REFERENCES dbo.TDocument_Types (DT_Key),
CONSTRAINT FK__TDocument_Imports__DIM_ImportedBy FOREIGN KEY
(DIM_ImportedBy) REFERENCES dbo.TUser (UR_LoginID),
CONSTRAINT CK__TDocument_Imports__BlankFileName CHECK ([DIM_Filename]
<> '')
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
-- TADODataSet CommandText
DECLARE @ResultCount AS int
SET @ResultCount = ISNULL(:ResultCount, 0)
SET ROWCOUNT @ResultCount
SELECT DIM_Key,
DIM_Filename,
DIM_DocType,
DIM_DateImported,
DIM_ImportedBy,
DIM_Object,
DIM_Text,
DATALENGTH(DIM_Object) AS DocumentSize
FROM dbo.TDocument_Imports
WHERE DIM_Key = ISNULL(:DIM_Key, DIM_Key)
AND DIM_DocType = ISNULL(:DIM_DocType, DIM_DocType)
AND DIM_ImportedBy LIKE ISNULL(:DIM_ImportedBy, '%')
-- TADOCommand
object dsDocImport: TADODataSet
Connection = ConfigConn
Parameters = <
item
Name = 'ResultCount'
Attributes = [paSigned, paNullable]
DataType = ftInteger
Precision = 10
Size = 4
Value = Null
end
item
Name = 'DIM_Key'
Attributes = [paSigned, paNullable]
DataType = ftInteger
Precision = 10
Size = 4
Value = Null
end
item
Name = 'DIM_DocType'
Attributes = [paSigned, paNullable]
DataType = ftInteger
Precision = 10
Size = 4
Value = Null
end
item
Name = 'DIM_ImportedBy'
Attributes = [paNullable]
DataType = ftString
NumericScale = 255
Precision = 255
Size = 15
Value = Null
end>
Left = 280
Top = 16
object dsDocImportDIM_Key: TIntegerField
FieldName = 'DIM_Key'
ProviderFlags = [pfInKey]
end
object dsDocImportDIM_Filename: TStringField
FieldName = 'DIM_Filename'
Required = True
Size = 256
end
object dsDocImportDIM_DocType: TIntegerField
FieldName = 'DIM_DocType'
Required = True
end
object dsDocImportDIM_DateImported: TDateTimeField
FieldName = 'DIM_DateImported'
end
object dsDocImportDIM_ImportedBy: TStringField
FieldName = 'DIM_ImportedBy'
Size = 15
end
object dsDocImportDIM_Object: TBlobField
FieldName = 'DIM_Object'
ProviderFlags = [pfInUpdate]
Required = True
end
object dsDocImportDIM_Text: TMemoField
FieldName = 'DIM_Text'
ProviderFlags = [pfInUpdate]
BlobType = ftMemo
end
object dsDocImportDocumentSize: TIntegerField
FieldName = 'DocumentSize'
ProviderFlags = []
ReadOnly = True
end
end
Brandon
--
"In the beginning the universe was created. This has made a lot of
people very angry, and has been widely regarded as a bad move." -
Douglas Noel Adams (1952-2001)
|
|
| Back to top |
|
 |
Brandon Lilly Guest
|
Posted: Tue Jul 22, 2003 6:05 pm Post subject: Re: Something changes ReadOnly to True |
|
|
Actually, this is valid functionality - I do this in many other
places.
It is necessary to assign your own value of DIM_Key when working with
multiple records or else you get key violations when you attempt to
post the second inserted record on the client. I assign sequentially
negative numbers for the DIM_Key on the client. In all other
manifestations of this, the value assigned to DIM_Key is ignored in
the insert (since I do not include it in the update). In the
afterupdaterecord event, the actual identity value is reassigned to
the DIM_Key.NewValue so that it can be propogated back to the client.
This is the standard method outlined by Dan Miser
(http://bdn.borland.com/article/0,1410,20847,00.html)
As I mentioned, this is working perfectly fine in many other modules
of our AppServer, so i am confused as to why this particular dataset
is getting these errors. Nothing appears to be different.
Below is the same information for a working set of components for
comparison:
CREATE TABLE dbo.TLocation (
LO_Key int IDENTITY (1, 1) NOT NULL ,
LO_Code varchar (5) NOT NULL ,
LO_Name varchar (40) NOT NULL ,
LO_Address1 varchar (30) NOT NULL ,
LO_Address2 varchar (30) NOT NULL CONSTRAINT
DF__TLocation__LO_Address2 DEFAULT (''),
LO_City varchar (20) NOT NULL ,
LO_State char (2) NOT NULL ,
LO_ZipKey int NOT NULL ,
CONSTRAINT PK__TLocation PRIMARY KEY CLUSTERED (LO_Key) ON PRIMARY
,
CONSTRAINT UQ__TLocation__LO_Code UNIQUE NONCLUSTERED (LO_Code) ON
PRIMARY ,
CONSTRAINT FK__TLocation__LO_State FOREIGN KEY (LO_State) REFERENCES
dbo.TState (ST_Code),
CONSTRAINT FK__TLocation__LO_ZipKey FOREIGN KEY (LO_ZipKey)
REFERENCES dbo.TZip_Code (ZP_Key),
) ON [PRIMARY]
SELECT LO_Key,
LO_Code,
LO_Name,
LO_Address1,
LO_Address2,
LO_City,
LO_State,
LO_ZipKey,
FROM dbo.TLocation
WHERE LO_Key = ISNULL(:LO_Key, LO_Key)
AND LO_Code LIKE ISNULL(:LO_Code, '%')
object dsServiceLocation: TADODataSet
Connection = ConfigConn
CursorType = ctStatic
LockType = ltReadOnly
Parameters = <
item
Name = 'LO_Code'
Attributes = [paNullable]
DataType = ftString
NumericScale = 255
Precision = 255
Size = 5
Value = Null
end
item
Name = 'LO_Key'
Attributes = [paSigned]
DataType = ftInteger
Precision = 10
Size = 4
Value = Null
end>
Left = 36
Top = 288
object dsServiceLocationLO_Key: TIntegerField
FieldName = 'LO_Key'
ProviderFlags = [pfInKey]
end
object dsServiceLocationLO_Code: TStringField
DisplayLabel = 'Code'
FieldName = 'LO_Code'
Size = 5
end
object dsServiceLocationLO_Name: TStringField
DisplayLabel = 'Name'
FieldName = 'LO_Name'
Size = 40
end
object dsServiceLocationLO_Address1: TStringField
DisplayLabel = 'Address1'
FieldName = 'LO_Address1'
Size = 30
end
object dsServiceLocationLO_Address2: TStringField
DefaultExpression = ''''''
DisplayLabel = 'Address2'
FieldName = 'LO_Address2'
Size = 30
end
object dsServiceLocationLO_City: TStringField
DisplayLabel = 'City'
FieldName = 'LO_City'
end
object dsServiceLocationLO_State: TStringField
DisplayLabel = 'State'
FieldName = 'LO_State'
FixedChar = True
Size = 2
end
object dsServiceLocationLO_ZipKey: TIntegerField
FieldName = 'LO_ZipKey'
end
end
Brandon
--
"In the beginning the universe was created. This has made a lot of
people very angry, and has been widely regarded as a bad move." -
Douglas Noel Adams (1952-2001)
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|