MS SQL Server & Grid (update/insert query)

Hello!

I connected the SmartClient to MS SQL Server. When I execut update/insert query (when I work with the grid), I get error: dont let to change identity field.

I see query (for example): "update … id = ‘1’ where id = ‘1’ ".

If this field ID not identity, then I must calculate and enter the ID manually. :frowning:

Can I change the query: to delete the first words " id = ‘1’ " from query?

Thanks!

Have you flagged the ‘id’ field as primaryKey=“true” in your DataSource?

Yes:

isc.DataSource.create({
tableName:“Regions”,
ID:“Regions”,
fields:{
RegId:{type:“int”, title:“ID”, name:“RegId”, canEdit:false, required:false, hidden:true, primaryKey:true},
Name:{
type:“char”,
title:“Name”,
name:“Name”,
length:1024,
required:true
}
},
serverType:“sql”
})

<DataSource >
<ID>Regions</ID>
<dataFormat>iscServer</dataFormat>
<serverType>sql</serverType>
<fields>
<DataSourceField name=“RegId” type=“int” required=“true” title=“ID” hidden=“true” primaryKey=“true”/>
<DataSourceField name=“Name” type=“char” required=“true” length=“1024” title=“Name”/>
</fields>
<tableName>Regions</tableName>
<dataBaseId>PENZAPORTAL</dataBaseId>
</DataSource>

Hello itgroup,

The DataSource you’ve shown doesn’t have the field called “id” you showed in your SQL statement, and also sets hidden=true on the primaryKey field, so that it wouldn’t appear in the grid and there’s no way the user could edit it, hence it wouldn’t appear in the update values or SQL statement.

This is an incomplete and conflicting picture - can you try reproducing your issue by modifying one of the provided examples, using one of the sample DataSources?

Hello!

About “id” - I show query “for example”.
About try reproducing issue by modifying one of the provided examples - I try it…

I delete properties “identity” && create trigger for find next ID. I think, my issue is done…

Thanks for reply!