registration form
-
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
-
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
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