加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Generating a GUID with VB.NET

发布时间:2020-12-16 23:49:57 所属栏目:大数据 来源:网络整理
导读:Introduction This code generates Globally Unique Identifier ( GUID ),which can be used to uniqually identify elements in a database. GUIDs identify objects such as interfaces and class objects. A GUID consists of one group of 8 hexadecimal

Introduction

This code generates Globally Unique Identifier (GUID),which can be used to uniqually identify elements in a database.

GUIDs identify objects such as interfaces and class objects. A GUID consists of one group of 8 hexadecimal digits,followed by three groups of 4 hexadecimal digits each,which are followed by one group of 12 hexadecimal digits.

Possessing a unique identifier makes it easy to store and retrieve information. This is especially useful when working with a database because a GUID makes an excellent primary key.

SQL Server integrates well with GUID usage. The SQL Server data type uniqueidentifier stores a GUID value. You can either generate this value within SQL Server—using the NEWID() function—or you can generate the GUID outside of SQL Server and insert it manually.

The base System class in the .NET Framework includes the GUID value type. In addition,this value type includes methods to work with GUID values. In particular,the NewGUID method allows you to easily generate a new GUID.

Language and Platform

VB.NET 2005

Compiler

This code segment is for VB.NET 2005

Version

1.0.0.0

Code

    Private Sub GenerateGUID()
        Dim strGUID As String        
        strGUID = System.Guid.NewGuid.ToString()        
        MessageBox.Show(strGUID )
    End Sub

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读