Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 Invalid Connection

Author  Topic 

seefresh
Starting Member

3 Posts

Posted - 2007-03-23 : 02:35:00
Hi folks.

I'm a programmer, and very new to databases... but I've worked with 7 or 8 of them so far and I've had no problems. I just had a client get himself a server. He got it from his friend and that friend set it up and sent me the info. It has .NET 2.0 and 1.1 and it has MSSQL Server 2005 Express. He sent me the login info for the database and I connected fine via my enterprise manager... but, when I try to connection asp.net I get "invalid connection" I'm using the exact same info. I've tried setting the server as (local) and as the web address I used in my enterprise manager. I recieved the same error for both.

Any suggestions welcome, thanks!

Chris

mikewa
Microsoft SQL Server Product Team

84 Posts

Posted - 2007-03-23 : 11:45:07
Hi Chris,

First off, you can't use (local) when trying to connect to SQL Express on a different computer. The use of (local) indicates connections to SQL Server on the same computer where your code is running. Beyond that I can't give you much help without knowing the connection string you're using and the full text of the error message.

Regards,
Mike Wachal
SQL Express

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Go to Top of Page

seefresh
Starting Member

3 Posts

Posted - 2007-03-23 : 17:58:40
Here is my connection string:
SERVER=(local);DATABASE=#####;UID=#####;PASSWORD=# ######

and

SERVER=the.address.to.server;DATABASE=#####;UID=## ##;PASSWORD=####


It is on the local server. I've done this many times and never had this problem.
Go to Top of Page

seefresh
Starting Member

3 Posts

Posted - 2007-03-23 : 18:26:07
Oh, sorry, and here is the full error:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Invalid connection.
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: Invalid connection.

Source Error:


Line 27: Dim objCommand As SqlCommand = New SqlCommand(strSQL, objConnection)
Line 28: Dim objDataReader As SqlDataReader
Line 29: objConnection.Open()
Line 30: objDataReader = objCommand.ExecuteReader
Line 31: Do While objDataReader.Read = True


Source File: C:\Inetpub\tj\dbadmin\admin.aspx Line: 29

Stack Trace:


[SqlException: Invalid connection.]
System.Data.SqlClient.ConnectionPool.CreateConnection() +406
System.Data.SqlClient.ConnectionPool.UserCreateRequest() +151
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +386
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
ASP.admin_aspx.__Render__control1(HtmlTextWriter __output, Control parameterContainer) in C:\Inetpub\tj\dbadmin\admin.aspx:29
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +27
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Page.ProcessRequestMain() +1926


Go to Top of Page

mikewa
Microsoft SQL Server Product Team

84 Posts

Posted - 2007-04-02 : 11:49:10
Hi Chris,

I don't see anything wrong with your connection string as long as SQL Express was isntalled as the default instance, which is not the default for SQL Express. If this is a defalut installation of SQL Express, you must specify the instance name in your connection string, which is normally (local)\SQLEXPRESS. Check the SQL Configuration Manager on the server to verify the name of the instance.

Regards,
Mike Wachal
SQL Express

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Go to Top of Page

ahdwindsurfdude
Starting Member

1 Post

Posted - 2007-08-07 : 11:21:27
Was receiving "Invalid connection." from .NET application

1. Started Microsoft SQL Server 2005 Configuration Manager.
2. Under SQL Server 2005 Network Configuration > Protocols I enabled TCP/IP Protocal for the database instance.
3. Under SQL Native Client Configuration > Aliases I added a new alias for the database instance.
Presto!
Go to Top of Page
   

- Advertisement -