Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
if(password == confirmpassword)
            {
                try
                {
                    SqlConnection connection = new SqlConnection("Data Source=VASPAAN2-PC;Initial Catalog=employee;User ID=sa;Password=2012");
                    connection.Open();
                    SqlCommand cmd = new SqlCommand("insetuser", connection);
                    
                    //SqlCommand cmd=new SqlCommand("insert into tbluser(username,password,address)values(@username,@password,@address)",sql);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@username", username);
                    cmd.Parameters.AddWithValue("@password", password);
                    cmd.Parameters.AddWithValue("@address", address);
                    cmd.ExecuteNonQuery();
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetMessage("data is inserted");
                    alert.Create();
                    alert.Show();
                    connection.Close();
                }
                catch (Exception ex)
                {
                    string err = ex.Message;
                    AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
                    alertbox.SetMessage(err);
                    alertbox.Create();
			        alertbox.Show();
                }
             
            }
            else
            {
                Toast.MakeText(this,"enter does not match", ToastLength.Short).Show();
            }

Error : server does not exsits orconnection refused.Give solution to connect to server.
Posted
Updated 8-Oct-13 2:37am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900