tricksjilo.blogg.se

Windows generate random string
Windows generate random string








windows generate random string

The full name of GUID is globally unique identifier, In addition, it is best not to splice SQL like this, but use parameters: cmd.CommandText = "SELECT * FROM t1 WHERE id = OdbcType.Int).Value = 4 Try to use GUID: string uniqueString = ().ToString() So there should be two steps: 1) generate a random 5 character string, lower case letter only 2) check if the string is in database, if yes, regenerate a random string until it is not in the database. How to write a method to gerate a unique string (lowcase a-z letter only lenth: 5)? Unique means: the generated string cannot be the one already in Database TableUser field GeneratedUniqueString. Public static void GenerateRandomUniqueString() if the connection is not already open - then open it + "') WHERE Username ='" + Environment.UserName + "'", Cn) OdbcCommand cmd = new OdbcCommand("INSERT into TableUser (GeneratedUniqueString) Values ('" +. Using (OdbcConnection Cn = new OdbcConnection(GlobalVariables.DatabaseConnectionString)) When user clicks the button, the program will generate a unique string for his/her own record. private void buttonInsertString_Click(object sender, EventArgs e)

#Windows generate random string how to

How should I write the method and how to call it? I will create a button and let user to generate a unique string for his/her own record.










Windows generate random string