Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. registration form

registration form

Scheduled Pinned Locked Moved ASP.NET
database
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sritha
    wrote on last edited by
    #1

    code written in register button click event protected void Button1_Click(object sender, System.EventArgs E) { //Response.Redirect("confirm.aspx"); if((txtid.Text=="") || (txtfname.Text=="") ||( txtlname.Text=="") || (txtnick.Text=="") || (txtadd.Text=="") || (txtpost.Text=="") || (txtmobile.Text=="") || (txtbdate.Text=="") || (txtemailadd.Text=="") || (txtconfirmpss.Text=="") || (txtyourans.Text=="")) Labelerror.Text =" sorry you for got to input the required fields"; else { SqlConnection conn = new SqlConnection(Application["ConnectionString"].ToString()); String insertCmd = "insert into users values (@StudentID," + "@password, @FirstName, @LastName,@secretquestion, @NickName,@Sex ,@Address, @PostalCode," + " @HomePhone,@MobilePhone,@Religion,@Birthdate,@MaritalStatus,@Title,"+ "@EmailAddress,@answer )"; // Initialize the SqlCommand with the new SQL string // and the connection information. SqlCommand myCommand = new SqlCommand(insertCmd, conn); conn.Open(); // Create new parameters for the SqlCommand object and // initialize them to the input-form field values. myCommand.Parameters.Add(new SqlParameter("@StudentID", SqlDbType.NVarChar , 10)); myCommand.Parameters["@StudentID"].Value = txtid.Text; myCommand.Parameters.Add(new SqlParameter("@password", SqlDbType.NVarChar , 15)); myCommand.Parameters["@password"].Value = txtconfirmpss.Text ; myCommand.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.NVarChar , 30)); myCommand.Parameters["@FirstName"].Value = txtfname.Text; myCommand.Parameters.Add(new SqlParameter("@LastName", SqlDbType.NVarChar , 50)); myCommand.Parameters["@LastName"].Value = txtlname.Text; myCommand.Parameters.Add(new SqlParameter("@secretquestion", SqlDbType.NVarChar , 50)); myCommand.Parameters["@secretquestion"].Value = Drops.SelectedItem.Text; myCommand.Parameters.Add(new SqlParameter("@NickName", SqlDbType.NVarChar , 20)); myCommand.Parameters["@NickName"].Value = txtnick.Text; myCommand.Parameters.Add(new SqlParameter("@Sex", SqlDbType.NVarChar , 20)); myCommand.Parameters["@Sex"].Value = Dropsex.SelectedItem.Text; myCommand.Parameters.Add(new SqlParameter("@Address", SqlDbType.NVarChar , 255)); myCommand.Parameters["@Address"].Value = txtadd.Text; myCommand.Parameters.Add(new SqlPara

    A 1 Reply Last reply
    0
    • S sritha

      code written in register button click event protected void Button1_Click(object sender, System.EventArgs E) { //Response.Redirect("confirm.aspx"); if((txtid.Text=="") || (txtfname.Text=="") ||( txtlname.Text=="") || (txtnick.Text=="") || (txtadd.Text=="") || (txtpost.Text=="") || (txtmobile.Text=="") || (txtbdate.Text=="") || (txtemailadd.Text=="") || (txtconfirmpss.Text=="") || (txtyourans.Text=="")) Labelerror.Text =" sorry you for got to input the required fields"; else { SqlConnection conn = new SqlConnection(Application["ConnectionString"].ToString()); String insertCmd = "insert into users values (@StudentID," + "@password, @FirstName, @LastName,@secretquestion, @NickName,@Sex ,@Address, @PostalCode," + " @HomePhone,@MobilePhone,@Religion,@Birthdate,@MaritalStatus,@Title,"+ "@EmailAddress,@answer )"; // Initialize the SqlCommand with the new SQL string // and the connection information. SqlCommand myCommand = new SqlCommand(insertCmd, conn); conn.Open(); // Create new parameters for the SqlCommand object and // initialize them to the input-form field values. myCommand.Parameters.Add(new SqlParameter("@StudentID", SqlDbType.NVarChar , 10)); myCommand.Parameters["@StudentID"].Value = txtid.Text; myCommand.Parameters.Add(new SqlParameter("@password", SqlDbType.NVarChar , 15)); myCommand.Parameters["@password"].Value = txtconfirmpss.Text ; myCommand.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.NVarChar , 30)); myCommand.Parameters["@FirstName"].Value = txtfname.Text; myCommand.Parameters.Add(new SqlParameter("@LastName", SqlDbType.NVarChar , 50)); myCommand.Parameters["@LastName"].Value = txtlname.Text; myCommand.Parameters.Add(new SqlParameter("@secretquestion", SqlDbType.NVarChar , 50)); myCommand.Parameters["@secretquestion"].Value = Drops.SelectedItem.Text; myCommand.Parameters.Add(new SqlParameter("@NickName", SqlDbType.NVarChar , 20)); myCommand.Parameters["@NickName"].Value = txtnick.Text; myCommand.Parameters.Add(new SqlParameter("@Sex", SqlDbType.NVarChar , 20)); myCommand.Parameters["@Sex"].Value = Dropsex.SelectedItem.Text; myCommand.Parameters.Add(new SqlParameter("@Address", SqlDbType.NVarChar , 255)); myCommand.Parameters["@Address"].Value = txtadd.Text; myCommand.Parameters.Add(new SqlPara

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      First of all your post is looks like Crap.

      sritha wrote:

      An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

      Did you tried to google it ? This is one of the most common error for connecting with SQL server . Which SQL Server Version are you using?

      cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups