字节数组GUID必须完全16字节长 [英] Byte array for guid must be exactly 16 bytes long

查看:643
本文介绍了字节数组GUID必须完全16字节长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想插入的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆