Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sequence GUID
Message
From
08/05/2009 12:06:55
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
08/05/2009 10:11:21
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
C# 3.0
OS:
Windows Server 2008
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01398391
Message ID:
01398655
Views:
78
>Hi,
>Thank you.
>
>I tried out the code (code posted here and also from Jimmy one), and found that it is not generated in sequence as well. The way I test is
>
>1. Defined an array contains 5 elements.
>2. Call the COMBGuid 5 times and assigned the return value to each element accordingly 0..1..2..3..4..5
>3. Copy the guid value of each array elements to guid column of each record in table.
>4. ORDER the guid column
>
>Result, the sequence of record doesn't same as the order of array element.
>
>Is it the right way to test?
>
>Please advice. Thank you

As per CC, I am not clear what does 'code posted here and from the Jimmy one) mean. If you use the code in the link I provided, it creates sequential ids. Here is test code:
  public class testComb
  {
 static void Main()
 {
  SqlConnection cn = new SqlConnection(@"server=.\sqlexpress;trusted_connection=yes;database=test");
  SqlCommand cmd = new SqlCommand();
  cmd.Connection = cn;
  cn.Open();
  
  cmd.CommandText = "create table myGuids (guidNo int, guidValue uniqueidentifier)";
  cmd.ExecuteNonQuery();
  
  cmd.CommandText = "insert into myGuids (guidNo, guidValue) values (@guidNo, @guidValue)";
  SqlParameter p1 = new SqlParameter("@guidNo",SqlDbType.Int);
  SqlParameter p2 = new SqlParameter("@guidValue",SqlDbType.UniqueIdentifier);
  cmd.Parameters.Add( p1 );
  cmd.Parameters.Add( p2 );
  
  for(int i=1;i<20;i++)
  {
	DateTime ts = DateTime.Now;
    p1.Value = i;
    p2.Value = GuidComb.NewComb(); // this is the one I refer in the link
    cmd.ExecuteNonQuery();
	while ( ts == DateTime.Now ) {}
  }

  SqlCommand cmdSelect = new SqlCommand("select * from myGuids order by guidValue", cn);
  SqlDataReader reader = cmdSelect.ExecuteReader();

  DataTable tbl = new DataTable();
  tbl.Load(reader);
  
  cn.Close();
  Form f = new ShowDataForm(tbl,"GUIDs");
  f.ShowDialog();
 }
}

 public class ShowDataForm : Form
{
  public ShowDataForm(DataTable tbl, string caption)
  {
     this.dgv = new System.Windows.Forms.DataGridView();
     this.dgv.Location = new System.Drawing.Point(0, 0);
     this.dgv.Dock = DockStyle.Fill;
     this.dgv.DataSource = tbl;
     this.Text = caption;
     this.Controls.Add(this.dgv);
     this.ClientSize = new System.Drawing.Size(1024, 768);
  }
  private System.Windows.Forms.DataGridView dgv;
}
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform