J'ai une petite fonction qui peut aider : elle retourne un GUID.
// myConnection doit etre une connection SQL valide.
public static Guid GetUniqueID()
{
string SQLString = "Set @NewGuid=newid()";
SqlParameter paramCount = new SqlParameter("@NewGuid", SqlDbType.UniqueIdentifier);
paramCount.Direction = ParameterDirection.Output;
SqlCommand CommandTest = new SqlCommand(SQLString, myConnection);
CommandTest.CommandType = CommandType.Text;
CommandTest.Parameters.Add(paramCount);
Program.myConnection.Open();
CommandTest.ExecuteNonQuery();
Program.myConnection.Close();
return (Guid) CommandTest.Parameters["@NewGuid"].Value;
}
Loic MICHEL