Jump to content

connect asp.net with sql server


Matar
 Share

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...