日期:2014-05-18 浏览次数:21050 次
string[] orders = new string[]{ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
private string GetRandomCode() { char[] chars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; string code = string.Empty; for (int i = 0; i < 4; i++) { Random rnd = new Random(GetRandomSeed()); code += chars[rnd.Next(0, 10)].ToString(); } return code; } private int GetRandomSeed() { byte[] bytes = new byte[4]; System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider(); rng.GetBytes(bytes); return BitConverter.ToInt32(bytes, 0); }
------解决方案--------------------
--发个SQL SERVER 版本的 declare @sql varchar(6) set @sql='' select top 6 @sql=@sql+char(number) from master..spt_values where number between 48 and 57 or number between 97 and 122 and type='p' order by newid() select @sql go 10 /* 60xrya dvs01k zkbgt6 f4siwr 8gihc9 gw3kdq hg4q18 ng0p8f o7dnfa d1vx9q */
------解决方案--------------------