简体   繁体   中英

C# type corresponding to T-SQL's INT(32) (possibly NAN)

My C# manipulates ID's read from the Database. Originally, they are stored in CHAR(32) NOT NULL format. (that's the table's primary key)

Once in C#, this is converted to Int32 (logically ?)

But when I need to insert those values back into another table with a similar structure, but where the primary key's type is INT IDENTITY(1, 1) NOT NULL) , I (logically) get the following error, as most CHAR(32) are not valid integers :

Input string was not in a correct format.Couldn't store in ID Column. Expected type is Int32.

Assuming that I want to keep the INT type for my target ID column, how should the C# code send the "E6802AA26C748A5A0EDE987384D2C48" to the SQL server for it not to complain that this is not a true Integer ?

E6802AA26C748A5A0EDE987384D2C48 is not an Int32. It's a GUID. You'd need 128 bits to store it, not 32.

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