0

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

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by sknake
0

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));
0
private void button4_Click(object sender, EventArgs e)
    {
      string tempPassword = Guid.NewGuid().ToString().Split(new char[] { '-' })[0];
    }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.