字节数组GUID必须完全16字节长 [英] Byte array for guid must be exactly 16 bytes long
问题描述
我想插入的Guid到我的Asp.net项目作为一个唯一的标识符。我们定义的表列长度为16。当我将数据插入我得到一个异常:数据太长
- 但是当我增加列的长度,它更改为字节数组GUID必须完全16字节长
。
I'm trying to insert Guid into my Asp.net project as a unique identifier. We have defined the table column length to 16. When I insert Data I get an exception: Data is too long
- but when I increase the column length, it changes to byte array for guid must be exactly 16 bytes long
.
我曾尝试添加数据直通NHibernate的。数据库服务器是MySQL,列数据类型为: - 二进制
和长度: - 16
I have tried adding Data thru NHibernate. The database server is MySQL, column data type is :- BINARY
and length is :- 16
public class Myapp
public Guid Id { get; set; }
我们写code从铯页面获取数据:
We write code for getting Data from Cs page:
Myapp.Id =Guid.NewGuid();
我该如何解决呢?
How can I solve this?
推荐答案
如果您正在使用SQL Server有一种类型的的Guid
值唯一标识符
If you are using SQL Server there is a type for a Guid
value uniqueidentifier
这篇关于字节数组GUID必须完全16字节长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!