c# - sqlexception unhandled by user code -


When I try to load my web page, I experience this error, can anyone recommend this What is the reason for this and what is the solution?

A network related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the example name is correct and SQL Server is configured to allow remote connection. (Provider: Named Pipes Provider, Error: 40 - Can not open connection to SQL Server

This is the C # code

  string conStr = ConfigurationManager " Username, userpage, email, address, mobile no, first name, last name, date of birth, time of birth, time of birth, time of birth, time of birth, NRIC, gender) "; StrSqlCmd + = "values ​​(@ Username, @Userpwd, @email, @address, @mobileNo, @firstName, @lastName, @DateOfBirth, @nric, @gender)"; StrSqlCmd2 = "putting in the patient" + "(Allergy, Childhoodillness)"; StrSqlCmd2 + = "values ​​(@allergies, @Childhood_illness)"; // can create commands and query and creator SqlCommand cmd = all connections from new SqlCommand (strSqlCmd, connection); SqlCommand CMD2 = new SqlCommand (strSqlCmd2, connection); Cmd.Parameters.AddWithValue ("Username", UserName.Text); Cmd.Parameters.AddWithValue ("@ Userpwd", password. Text); Cmd.Parameters.AddWithValue ("@ Email", Email Text); Cmd.Parameters.AddWithValue ("@ address", address.text); Cmd.Parameters.AddWithValue ("Mobile Noo", MobileNo.Text); Cmd.Parameters.AddWithValue ("First name", password. Text); Cmd.Parameters.AddWithValue ("Last name", password. Text); Cmd.Parameters.AddWithValue ("@ DateOfBirth", DOB.Text); Cmd.Parameters.AddWithValue ("@Enrick", NRIC Test); Cmd.Parameters.AddWithValue ("pen, gender", text.); Cmd2.Parameters.AddWithValue ("Allergies", Allergy. Text); Cmd2.Parameters.AddWithValue ("@ spirit of childhood", sense of childhood. Lessons); Connection.Open (); Cmd.ExecuteNonQuery (); Cmd2.ExecuteNonQuery (); Connection.Close ();   

This web.config code

  & lt; Add name = "MSSQLConnectionString" connectionstring = "server = local host; database = App_Data \ PMS.mdf; integrated security = true" provider name = "System.Data.SqlClient" />  

This error is self explanatory and this means that an error with your connection string is . You can locate the wrong server name, or invalid database name. In addition, if it's all right, you can see the configuration manager and check to see if SQL Server is ready to accept remote requests or not. (This is to connect to remote.)

You can get useful tips about connection strings in the following URLs:

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -