简体   繁体   中英

How to check if column in SQL SERVER is auto increment in C#?

I have a problem where I have to insert some data into table in SQL SERVER, from my C# program, but I don't know which columns are auto increment? Is there any way on how to find these columns so I don't insert values into those columnns?

This is not a C# operation. This is the kind of operation that can only be done reliably in the DBMS. The tables being setup properly and staying setup properly is the DB Adminsitrators job. Maybe the job of your instaler programm. Know the shema, do not try to "guess" it.

I do not think it is worthwhile to spend resources on verifying this. I do check if a retreiving of the Passwrod Hash & salt by username returns more then result (while Name might not be a PK, it should still be unique), but beyond that the DB is simply something I have to trust. It acting unexpectedly is like the RAM acting unexpectedly - there is nothing you can do to fix it and detection is a Administrators job.

You can either trust nearly everything of the DB, or you simply can not trust the DB.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM