public XmlElement GetUserDetails(string Name)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ToString());
con.Open();
SqlCommand cmd = new SqlCommand("select * from Customers where Name like @Name+'%'", con);
cmd.Parameters.AddWithValue("@Name", Name);
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
// Create an instance of DataSet.
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
// Return the DataSet as an XmlElement.
XmlDataDocument xmldata = new XmlDataDocument(ds);
XmlElement xmlElement = xmldata.DocumentElement;
return xmlElement;
}
In the web.config file, I have written the following code:
I get the following error :
VB.NET
System.Data.SqlClient.SqlException: 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Manikavelu VelayuthamRank #413 · 6K reputationPosted Jan 13, 2013, 12:56 AM EST
Try to connect the database in Sql Server through windows authentication, if that works, this also should work.