Not getting ID from tables
Not getting ID from tables
PatricioFink
Posts: 27Questions: 12Answers: 0
in Editor
Why i'm not getting the DB row ID from this request?:
This discussion has been closed.
Answers
Try adding
"ID"
as a third parameter to thenew Editor(...)
constructor, while also keeping yournew Field("ID")
. The default Editor looks for is "id" and the case might be getting confused somewhere.Allan
Nop, not workin. I even change the field name in the DB to "id" (lower case)
Hmm - weird. Could you send me a dump of your DB table (just the structure will do - don't need the data)? I'll try to reproduce it here.
Thanks,
Allan
USE XXX
GO
/****** Object: Table [dbo].[Clientes] Script Date: 11/3/2017 3:47:28 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Clientes](
[id] [int] IDENTITY(1,1) NOT NULL,
[Nombre] nvarchar NULL,
[Apellido] nvarchar NULL,
[Direccion] nvarchar NULL,
[Telefono] nvarchar NULL,
[Email] nvarchar NULL,
[Facebook] nvarchar NULL,
[Twitter] nvarchar NULL,
[Instagram] nvarchar NULL,
[Comercio_ID] [int] NOT NULL,
[CuentaCorriente_ID] [int] NULL,
[FechaDeIngreso] [datetime] NOT NULL,
CONSTRAINT [PK_Clientes] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Clientes] WITH CHECK ADD CONSTRAINT [FK_Clientes_Comercios] FOREIGN KEY([Comercio_ID])
REFERENCES [dbo].[Comercios] ([ID])
GO
ALTER TABLE [dbo].[Clientes] CHECK CONSTRAINT [FK_Clientes_Comercios]
GO
ALTER TABLE [dbo].[Clientes] WITH CHECK ADD CONSTRAINT [FK_Clientes_CuentaCorrientes] FOREIGN KEY([CuentaCorriente_ID])
REFERENCES [dbo].[CuentaCorrientes] ([ID])
GO
ALTER TABLE [dbo].[Clientes] CHECK CONSTRAINT [FK_Clientes_CuentaCorrientes]
GO
Like that?
Perfect - thanks. I've just tried this locally:
And I get this back from the server:
I put a single row into the table in the database with that data.
This is using SQL Express 13.
edit Can you show me the JSON you are getting back from the server?
Allan
You are right, i'm getting the ID from the DB, this is the reposnse:
But i can not show that in the table, i think that is because the ID is (of course) read only, and i'm not telling that anywhere in the code, right??
Do you get any error messages when you uncomment the
data: 'id'
line?Also, use
new Field("id").Set(false)
on the server-side to tell the C# code not to write any value to the database that was submitted by the client-side.Allan