Click here to Skip to main content
15,921,660 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionProblem in using javascript for validation Pin
janani135-May-09 23:53
janani135-May-09 23:53 
AnswerRe: Problem in using javascript for validation Pin
Vimalsoft(Pty) Ltd6-May-09 0:13
professionalVimalsoft(Pty) Ltd6-May-09 0:13 
GeneralRe: Problem in using javascript for validation Pin
janani136-May-09 0:35
janani136-May-09 0:35 
GeneralRe: Problem in using javascript for validation Pin
Vimalsoft(Pty) Ltd6-May-09 1:12
professionalVimalsoft(Pty) Ltd6-May-09 1:12 
QuestionA File System Web site Hosting in IIS Pin
indian1435-May-09 23:34
indian1435-May-09 23:34 
AnswerRe: A File System Web site Hosting in IIS Pin
Vimalsoft(Pty) Ltd6-May-09 0:17
professionalVimalsoft(Pty) Ltd6-May-09 0:17 
AnswerRe: A File System Web site Hosting in IIS Pin
Abhijit Jana6-May-09 0:44
professionalAbhijit Jana6-May-09 0:44 
Questionregistration form Pin
sritha5-May-09 23:30
sritha5-May-09 23:30 
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 SqlParameter("@PostalCode", SqlDbType.NVarChar , 20));
myCommand.Parameters["@PostalCode"].Value = txtpost.Text ;




myCommand.Parameters.Add(new SqlParameter("@HomePhone", SqlDbType.NVarChar , 40));
myCommand.Parameters["@HomePhone"].Value = txthphone.Text;


//mobile phone
myCommand.Parameters.Add(new SqlParameter("@MobilePhone", SqlDbType.NVarChar , 20));
myCommand.Parameters["@MobilePhone"].Value = txtmobile.Text;


myCommand.Parameters.Add(new SqlParameter("@Religion", SqlDbType.NVarChar , 20));
myCommand.Parameters["@Religion"].Value = Dropr.SelectedItem.Text;

myCommand.Parameters.Add(new SqlParameter("@Birthdate", SqlDbType.NVarChar , 20));
myCommand.Parameters["@Birthdate"].Value = txtbdate.Text ;

myCommand.Parameters.Add(new SqlParameter("@MaritalStatus", SqlDbType.NVarChar , 20));
myCommand.Parameters["@MaritalStatus"].Value =Dropmerit.SelectedItem.Text;



myCommand.Parameters.Add(new SqlParameter("@Title", SqlDbType.NVarChar , 50));
myCommand.Parameters["@Title"].Value =txttitle.Text;


myCommand.Parameters.Add(new SqlParameter("@EmailAddress", SqlDbType.NVarChar , 50));
myCommand.Parameters["@EmailAddress"].Value = txtemailadd.Text ;




myCommand.Parameters.Add(new SqlParameter("@answer", SqlDbType.NVarChar , 50));
myCommand.Parameters["@answer"].Value = txtyourans.Text ;


// conn.Close();
//conn.Open();

//myCommand.Connection.Open();
//myCommand.Connection.Open();
//conn.Open();

try
{

myCommand.ExecuteNonQuery();
//conn.ExecuteNonQuery();
Response.Redirect("confirm.aspx");
//Labelerror.Text=" new data has been added";
//Message.InnerHtml = "<b>Record Added</b><br>" + insertCmd;


}
catch (SqlException e)
{
if (e.Number == 2627)
Labelerror.Text = "ERROR: A record already exists with the same student ID";
else
Labelerror.Text = "ERROR: Could not add record, please ensure the fields are correctly filled out";
//Labelerror.Text = Convert.ToString(txtadd.Text);




}
finally
{
//myCommand.Connection.Close();
conn.Close();

}


//BindGrid();






}
}




the above code i have written for registration form for some project
but it is showing an error as follows

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)

i used the connection string in web.config as

<add name="ConnectionString" connectionString="server=.;Integrated security=true;Database=AustaExam"
providerName="System.Data.SqlClient" />
AnswerRe: registration form Pin
Abhijit Jana5-May-09 23:43
professionalAbhijit Jana5-May-09 23:43 
QuestionPNG images not pulling through in IIS Pin
Elizma5-May-09 23:15
Elizma5-May-09 23:15 
AnswerRe: PNG images not pulling through in IIS Pin
Andras Fuchs15-Sep-09 0:03
Andras Fuchs15-Sep-09 0:03 
Questioncannot detect User Control Pin
sameercodes5-May-09 23:01
sameercodes5-May-09 23:01 
AnswerRe: cannot detect User Control Pin
Spunky Coder5-May-09 23:28
Spunky Coder5-May-09 23:28 
QuestionVirtual Earth Bespoke Map Control help!!!! Pin
Lexter33335-May-09 22:36
Lexter33335-May-09 22:36 
QuestionHow would you create this? Pin
Mantaii5-May-09 22:35
Mantaii5-May-09 22:35 
AnswerRe: How would you create this? Pin
Mantaii6-May-09 23:48
Mantaii6-May-09 23:48 
QuestionFlash in PDF issue Pin
Abhishek Sur5-May-09 22:28
professionalAbhishek Sur5-May-09 22:28 
QuestionCharts in .NET Pin
liz35-May-09 21:51
liz35-May-09 21:51 
QuestionEntity Layer: Structure vs Class Pin
Anurag Gandhi5-May-09 21:50
professionalAnurag Gandhi5-May-09 21:50 
AnswerRe: Entity Layer: Structure vs Class Pin
Spunky Coder5-May-09 22:06
Spunky Coder5-May-09 22:06 
QuestionCrystal Report on Web Server Pin
yogesh_kumar_agarwal5-May-09 21:45
yogesh_kumar_agarwal5-May-09 21:45 
AnswerRe: Crystal Report on Web Server Pin
Dinesh Reghunath5-May-09 23:59
professionalDinesh Reghunath5-May-09 23:59 
GeneralRe: Crystal Report on Web Server Pin
yogesh_kumar_agarwal6-May-09 0:15
yogesh_kumar_agarwal6-May-09 0:15 
GeneralRe: Crystal Report on Web Server Pin
Dinesh Reghunath6-May-09 0:50
professionalDinesh Reghunath6-May-09 0:50 
QuestionAjax Timer control in ASP.Net Pin
scothykonma5-May-09 21:17
scothykonma5-May-09 21:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.