Cannot delete regs on a SQL table in Access
Asked Answered
J

0

2

I have a SQL Server table linked in an Access app. If I try to delete records with a delete query there is no problem. But if I try to delete records directly in table or using a select query in datasheet mode Access doesn't allow me to delete the records and throws the following warning:

"The microsoft access database engine stopped the process because you and another user are attempting to change the same data at the same time."

The same happens when I try to update data. There is no other user modifying the data.

The problem is that we still have a lot of legacy forms that uses datasheet mode to alter o delete records instead of using queryes and, for now, changing all these forms is unthinkable.

¿Has anyone any idea of what could be happening?

Thanks!

FINAL EDIT: The problem was a bit field that was set to nullable that, thanks to Kostas K. I discovered is not convertable to Access.

So, instead of this:

[FIELD] [bit] NULL

We need tis:

[FIELD] [bit] NOT NULL

ALTER TABLE [dbo].[TABLE] ADD DEFAULT ((0)) FOR [FIELD] GO

UPDATE: This locking only happens with new records added from Access, but not with the original records of the SQL table.

This is the script to create the table:

`

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [Chapas].[INFO_CHAPAS](
[ID_INFO_CHAPA] [int] IDENTITY(1,1) NOT NULL,
[COD_EQUIPO] [int] NULL,
[EQUIPO] [nvarchar](255) NULL,
[NUMERO_SERIE] [nvarchar](255) NULL,
[FASES] [nvarchar](255) NULL,
[VOLTAJE] [nvarchar](255) NULL,
[FRECUENCIA] [nvarchar](255) NULL,
[POTENCIA] [nvarchar](255) NULL,
[AÑO] [int] NULL,
[IMPRESO] [bit] NULL,
[SELECTOR_REGISTRO] [bit] NULL,
[USUARIO] [int] NULL,
[FECHA_IMPRESION] datetime NULL

CONSTRAINT [INFO_CHAPAS_PK] PRIMARY KEY NONCLUSTERED 
(
[ID_INFO_CHAPA] 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 [Chapas].[INFO_CHAPAS] ADD  DEFAULT ((0)) FOR [IMPRESO]
GO

`

Jaconet answered 21/6, 2022 at 12:53 Comment(8)
Probably an issue with specific data types. Please add the full CREATE TABLE statement to your question, and also which ODBC driver you use.Forgave
Does "regs" mean "records"?Hurried
Yes, regs mean records. I'll edit the question with the full word.Jaconet
Please provide enough code so others can better understand or reproduce the problem.Twinned
Are you closing the recordset after you add the new record? Or are you using a stored procedure to insert the record? If it's a linked form - perhaps the new record is still in edit mode? Without your code we can only guessGowrie
Check data types on SQL server table, for example nullable BIT etc - Access cannot handle those.Humberto
@Gowrie In fact there is no code. I'm trying the very basic, that is operating directly on the bare table and the problem persists, so I discard problems with the form or with the query. I also checked datatypes and are simply varchar, int and bit with an identity(1,1) so nothing strange or not convertable to Access (afaik). I updated This is the script to create the table if that helps.Jaconet
@KostasK. That's it! The nullable bit... The problem was solved creating the bit field not nullable and with a default value of 0. Thank all of you for your time and ideas.Jaconet

© 2022 - 2024 — McMap. All rights reserved.