I have used "Ctrl+F" on your post for "ConnectionString" and found this :),
<add name="appConnection" connectionString="data source=.;initial catalog=manager_vdnextw; User id=vdnextw; Password=123456" providerName=" System.Data.SqlClient"/> (assuming you are using the same connection string) Is the application and database on same machine? If it is NOT then you should set the IP or Name of Database Server in "Data Source" Regards, Arsalan Tamiz On Dec 23, 8:26 pm, "hirendra singh" <[email protected]> wrote: > * hi > > SqlConnection con = new SqlConnection(cStr); > > con.Open(); > > code give an error any on give bast solution this code > its working fine in local mssql. > > its not working online working in server mssql. > please let me knw wer i'm wrong > here is my code > > Hirendra pratap singh > > Niit student > > thanks > 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) > > Description: An unhandled exception occurred during the execution of the > current web request. Please review the stack trace for more information > about the error and where it originated in the code. > > Exception Details: 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) > > Source Error: > > Line 33: > Line 34: con.ConnectionString = conn;Line 35: > con.Open();Line 36: int i; > Line 37: i = 0; > > using System; > > using System.Data; > > using System.Configuration; > > using System.Collections; > > using System.Web; > > using System.Web.Security; > > using System.Web.UI; > > using System.Web.UI.WebControls; > > using System.Web.UI.WebControls.WebParts; > > using System.Web.UI.HtmlControls; > > using System.Net.Mail; > > using System.Data.SqlClient; > > public partial class Signup : System.Web.UI.Page > > { > > SqlConnection con = new SqlConnection(); > > string conn = ConfigurationManager.ConnectionStrings["appConnection" > ].ConnectionString; > > protected void Page_Load(object sender, EventArgs e) > > { > > -----some code here > > } > > protected void Button3_Click1(object sender, EventArgs e) > > { > > con.ConnectionString = conn; > > con.Open(); > > int i; > > i = 0; > > SqlCommand cmd2 = new SqlCommand("select [username] from userinfo2 where" + > "(([usernam...@username))", con); > > cmd2.Parameters.Add("@username", SqlDbType.VarChar, 50); > > cmd2.Parameters["@username"].Value = txtusername.Text; > > SqlDataReader dr; > > dr = cmd2.ExecuteReader(CommandBehavior.CloseConnection); > > while (dr.Read()) > > { > > i = 1; > > } > > if (i == 1) > > { > > LblUN.Visible = true; > > LblUN.Text = txtusername.Text + " is not available"; > > } > > else if (txtusername.Text == "") > > { > > LblUN.Visible = true; > > LblUN.Text = "Please enter the value"; > > } > > else > > { > > LblUN.Visible = true; > > LblUN.Text = txtusername.Text+" is available"; > > } > > dr.Close(); > > con.Close(); > > } > > * ** *+++++++++++++++++++++++++++* > > <?xml version="1.0"?> > > <configuration> > > <configSections> > > <sectionGroup name="system.web.extensions" > type="System.Web.Configuration.SystemWebExtensionsSectionGroup, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35"> > > <sectionGroup name="scripting" > type="System.Web.Configuration.ScriptingSectionGroup, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35"> > > <section name="scriptResourceHandler" > type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition=" > MachineToApplication" /> > > <sectionGroup name="webServices" > type="System.Web.Configuration.ScriptingWebServicesSectionGroup, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35"> > > <section name="jsonSerialization" > type="System.Web.Configuration.ScriptingJsonSerializationSection, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition=" > Everywhere" /> > > <section name="profileService" > type="System.Web.Configuration.ScriptingProfileServiceSection, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition=" > MachineToApplication" /> > > <section name="authenticationService" > type="System.Web.Configuration.ScriptingAuthenticationServiceSection, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition=" > MachineToApplication" /> > > </sectionGroup> > > </sectionGroup> > > </sectionGroup> > > </configSections> > > <system.web> > > <customErrors mode="Off" defaultRedirect="404.aspx" /> > > <!-- > > Set compilation debug="true" to insert debugging > > symbols into the compiled page. Because this > > affects performance, set this value to true only > > during development. > > --> > > <httpHandlers> > > <remove verb="*" path="*.asmx" /> > > <add verb="*" path="*.asmx" validate="false" > type="System.Web.Script.Services.ScriptHandlerFactory, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35" /> > > <add verb="*" path="*_AppService.axd" validate="false" > type="System.Web.Script.Services.ScriptHandlerFactory, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35" /> > > <add verb="GET,HEAD" path="ScriptResource.axd" > type="System.Web.Handlers.ScriptResourceHandler, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35" validate="false" /> > > <add verb="GET" path="ImageVerifier.axd" > type="NatsNet.Web.UI.Controls.ImageVerifier, > NatsNet.Web.UI.Controls" /> > > </httpHandlers> > > <httpModules> > > <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35" /> > > </httpModules> > > <compilation defaultLanguage="c#" debug="true" /> > > <globalization culture="en-US" uiCulture="en-US" /> > > </system.web> > > <system.web.extensions> > > <scripting> > > <webServices> > > <!-- Uncomment this line to customize maxJsonLength and add a custom > converter --> > > <!-- > > <jsonSerialization maxJsonLength="500"> > > <converters> > > <add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/> > > </converters> > > </jsonSerialization> > > --> > > <!-- Uncomment this line to enable the authentication service. Include > requireSSL="true" if appropriate. --> > > <!-- > > <authenticationService enabled="true" requireSSL = "true|false"/> > > --> > > <!-- Uncomment these lines to enable the profile service. To allow profile > properties to be retrieved > > and modified in ASP.NET AJAX applications, you need to add each property > name to the readAccessProperties and > > writeAccessProperties attributes. --> > > <!-- > > <profileService enabled="true" > > readAccessProperties="propertyname1,propertyname2" > > writeAccessProperties="propertyname1,propertyname2" /> > > --> > > </webServices> > > <!-- > > <scriptResourceHandler enableCompression="true" enableCaching="true" /> > > --> > > </scripting> > > </system.web.extensions> > > <system.webServer> > > <validation validateIntegratedModeConfiguration="false" /> > > <modules> > > <add name="ScriptModule" preCondition="integratedMode" > type="System.Web.Handlers.ScriptModule, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35" /> > > </modules> > > <handlers> > > <remove name="WebServiceHandlerFactory-Integrated" /> > > <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition=" > integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35" /> > > <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" > preCondition="integratedMode" > type="System.Web.Script.Services.ScriptHandlerFactory, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35" /> > > <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" > path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, > System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35" /> > > </handlers> > > </system.webServer> > > <connectionStrings> > > <add name="appConnection" connectionString="data source=.;initial > catalog=manager_vdnextw; User id=vdnextw; Password=123456" providerName=" > System.Data.SqlClient"/> > > <remove name="LocalMySqlServer" /> > > </connectionStrings> > > </configuration> > *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)* *Description: *An unhandled > exception occurred during the execution of the current web request. Please > review the stack trace for more information about the error and where it > originated in the code. > > *Exception Details: *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) > > * Server Error in '/' Application. > ------------------------------ > 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) Description: An unhandled > exception occurred during the execution of the current web request. Please > review the stack trace for more information about the error and where it > originated in the code. > > Exception Details: System.Data.SqlClient.SqlException: A network-related or > ... > > read more »
