You are on page 1of 1

String path1 = Server.MapPath("App_data/Company Database.

mdf");
String constring = "Data Source=.\\SQLEXPRESS;AttachDbFilename=" + path1
+ ";Integrated Security=True;User Instance=True";
SqlConnection cn = new SqlConnection(constring);
cn.Open();
string sql = "insert into user_detail values('" + txtname.Text + "','" +
txtaddress.Text + "','" + txtcity.Text + "','" + tpin.Text + "','" + ddldist.Se
lectedItem.Text + "','" + txtdob.Text + "','" + txtphone.Text + "','" + txtemail
.Text + "','" + txtuserid.Text + "','" + txtpassword.Text + "','" + txtconfirmpa
ssword.Text + "')";
SqlCommand cmd = new SqlCommand(sql, cn);
string sql1 = "select userid from user_detail where userid='" + txtuseri
d.Text + "'";
SqlCommand cmd1 = new SqlCommand(sql1, cn);
SqlDataReader rd;
rd = cmd1.ExecuteReader();
if (rd.Read())
{
Checkuser.Text = "user name is all ready taken";
}
else
{
rd.Close();
cmd.ExecuteNonQuery();
Response.Redirect("~/main.aspx");
}
cn.Close();

You might also like