protected void trigger() { try { DataSet ds = ExamManagement.SP.table2_SP_Selectall().GetDataSet(); if (ds.Tables[0].Rows.Count > 0) { string a = RandomNumberGenerator(4); string b = RandomNumberGenerator(4); string c = RandomNumberGenerator(4); ExamManagement.SP.table1_insert(a,b,c).Execute(); } } catch (SqlException ex) { ClientMessaging("Error :"+ex); } } public static string RandomNumberGenerator(int length) { System.Security.Cryptography.RandomNumberGenerator rng = System.Security.Cryptography.RandomNumberGenerator.Create(); char[] chars = new char[length]; //based on your requirment you can take only alphabets or number string validChars = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXzZ"; byte[] bytes = new byte[length-1]; for (int i = 0; i < length; i++) { rng.GetBytes(bytes); Random rnd = new Random(bytes[0]); chars[i] = validChars[rnd.Next(validChars.Length)]; } return (new string(chars)); }
Column1, varchar(max),null Column2, varchar(max),null Column3, varchar(max),null
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)