Hi,

In the registration form am abt to make, i want the system to generate the password for the user. The simple way to enter the data to the backend is :

SqlCommand cmd_insertuserDetail = new SqlCommand ("Insert into fwm_user (last_name, first_name, birth_date, address, city, postal_code, country, email, password, telephone, occupation, company)" +
                                       " values (@last_name, @first_name, @birth_date, @address, @city, @postal_code, @country, @email, @password, @telephone, @occupation, @company)", conn1);
      
            cmd_insertuserDetail.Parameters.Add(new SqlParameter("@last_name", txtLName.Text));
            cmd_insertuserDetail.Parameters.Add(new SqlParameter("@first_name", txtFName.Text));
            cmd_insertuserDetail.Parameters.Add(new SqlParameter("@birth_date", txtBirthdate.Text));
            cmd_insertuserDetail.Parameters.Add(new SqlParameter("@address", txtAddress.Text));
            cmd_insertuserDetail.Parameters.Add(new SqlParameter("@city", txtCity.Text));
            cmd_insertuserDetail.Parameters.Add(new SqlParameter("@postal_code", txtPostalCode.Text));
            cmd_insertuserDetail.Parameters.Add(new SqlParameter("@country", txtCountry.Text));
            cmd_insertuserDetail.Parameters.Add(new SqlParameter("@email", txtEmail.Text));
            //if (ValidateEmailAddress(txtEmail.Text))
            //{
            //    cmd_insertuserDetail.Parameters.Add(new SqlParameter("@email", txtEmail.Text));
            //}
            //else
            //{
            //    MessageBox.Show("Enter valid Email ID", "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            //}
            
            ???????????

            cmd_insertuserDetail.Parameters.Add(new SqlParameter("@telephone", txtTelephone.Text));
            cmd_insertuserDetail.Parameters.Add(new SqlParameter("@occupation", txtOccupation.Text));
            cmd_insertuserDetail.Parameters.Add(new SqlParameter("@company", txtCompany.Text));

password needs to be generated when user clicks on "submit" button.. what r the ways to generate a password... pls guide with both source code any any SQL procedures as required

Thanks

hi,

i go tthe single line solution for the same... anything better pls suggest

Thanks

string auto_pwd = System.Guid.NewGuid().ToString().Substring(0,10);
            cmd_insertuserDetail.Parameters.Add(new SqlParameter("@password", auto_pwd));
private void button4_Click(object sender, EventArgs e)
    {
      string tempPassword = Guid.NewGuid().ToString().Split(new char[] { '-' })[0];
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.