Click here to Skip to main content
15,886,857 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear sir;
when i run my website on visual studio . it gives me error
----
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 instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
-----
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;


public partial class WUC_Register1l : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Buttonregister_Click(object sender, EventArgs e)
{

// declaration
SqlConnection conn = new SqlConnection ();
SqlCommand cmd = new SqlCommand();

//required
conn.ConnectionString=ConfigurationManager.ConnectionStrings[1].ToString() ;

cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "ManageMember";
cmd.Parameters.AddWithValue("@check", "a");
cmd.Parameters.AddWithValue("@username", Txtusername.Text);
cmd.Parameters.AddWithValue("@password", Txtpass.Text);
cmd.Parameters.AddWithValue("@name", Txtname.Text);
cmd.Parameters.AddWithValue("@email", Txtmail.Text);
cmd.Parameters.AddWithValue("@phone", Txtphone.Text);
cmd.Parameters.AddWithValue("@company", Txtcompany.Text);
cmd.Parameters.AddWithValue("@gender", RadioButtongender.SelectedValue);
cmd.Parameters.AddWithValue("@birthday", Txtbirthday.Text);
cmd.Parameters.AddWithValue("@qustion", Txtquestion.Text);
cmd.Parameters.AddWithValue("@answer", Txtanswer.Text);




//DB work
conn.Open();
try
{
cmd.ExecuteNonQuery();
lblmsg.Text = "User Added Successfully";
}
catch(SqlException ex)
{
if (ex.Number == 2627)
lblmsg.Text = "Username already exists,Please changepassword Username";
else
lblmsg.Text = ex.Message;
}
-------------------
my mail is : nanat111@yahoo.com
Posted
Updated 13-Jun-15 8:08am
v2
Comments
F-ES Sitecore 13-Jun-15 15:58pm    
The connection string you are using does not contain a reference to a valid server, or for some reason your machine can't connect to that server. We don't know what your connection string is, what your server is, what instances are on it, we don't know if they're running, if you've misspelled something, maybe you're missing an instance name or using one when you don't need to, maybe you're reading the wrong string....we can't access your network so there is nothing we can to do help, we can only tell you that your connection string is wrong.
Member 11751141 14-Jun-15 16:27pm    
dear sir.
can i send you my source code
Member 11751141 14-Jun-15 16:38pm    
can i send my project

1 solution

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