Matar Posted October 2, 2006 Share Posted October 2, 2006 iam trying to connect asp.net with sql server database ,but there are a problem firstly this my code <%@ Import Namespace="System.Data.SqlClient" %><script Runat="Server">Sub Page_Load Dim conPubs As SqlConnection conPubs = New SqlConnection( "Server=localhost;uid=sa;pwd=secret;database=pubs" ) conPubs.Open()End Sub</Script>and this is the error :An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)i setup the surface area to allow the remote connection with tcp/ip and still the same error ?plz help Link to comment Share on other sites More sharing options...
aspnetguy Posted October 2, 2006 Share Posted October 2, 2006 your connection string is incorrect, here is a sampleData Source=(local);Initial Catalog=DBName;User ID=username;password=yourpassword;Trusted_Connection=yes; Link to comment Share on other sites More sharing options...
jesh Posted October 2, 2006 Share Posted October 2, 2006 This site (http://www.connectionstrings.com/) has saved me more times than I care to remember... Link to comment Share on other sites More sharing options...
Matar Posted October 3, 2006 Author Share Posted October 3, 2006 hi i try your comment and still the same error this is the code<%@ Import Namespace="System.Data.SqlClient" %><script runat =server > Sub page_load() Dim oSQLConn As SqlConnection = New SqlConnection() oSQLConn.ConnectionString = "Data Source=(local);Initial Catalog=pubs;User ID=sa;password=secret;Trusted_Connection=yes;" oSQLConn.Open() End Sub</script>this is the error :An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) Link to comment Share on other sites More sharing options...
aspnetguy Posted October 3, 2006 Share Posted October 3, 2006 here is some info ont he errorhttp://blogs.msdn.com/sql_protocols/archiv.../28/474698.aspx Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now