Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Data.SqlClient;
- public partial class _Default : System.Web.UI.Page
- {
- SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Dell\Documents\Visual Studio 2010\WebSites\RandomPassword\App_Data\Database.mdf;Integrated Security=True;User Instance=True");
- SqlCommand cmd = new SqlCommand();
- protected void Page_Load(object sender, EventArgs e)
- {
- cmd.Connection = con;
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- String pass = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#*&%$";
- Random r = new Random();
- char[] mypass = new char[8];
- for (int i = 0; i <= 7; i++)
- {
- mypass[i] = pass[(int)(42 * r.NextDouble())];
- }
- con.Open();
- Literal1.Text = "<strong>Your Password Is : </strong>";
- Label1.Text =new string(mypass).ToString();
- cmd.CommandText = "insert into Reg(Name,Mobile,Email,City,State,Password) values(@name,@mobile,@email,@city,@st,@pass)";
- cmd.Parameters.AddWithValue("@name",TextBox1.Text);
- cmd.Parameters.AddWithValue("@mobile",TextBox2.Text);
- cmd.Parameters.AddWithValue("@email",TextBox3.Text);
- cmd.Parameters.AddWithValue("@city",TextBox4.Text);
- cmd.Parameters.AddWithValue("@st",TextBox5.Text);
- cmd.Parameters.AddWithValue("@pass",Label1.Text);
- cmd.ExecuteNonQuery();
- con.Close();
- }
Add Comment
Please, Sign In to add comment