I can't get my website to connect to the built-in db for ASP.NET login funtions (ASPNETDB.MDF). I've been trolling multiple forums for weeks now, and nothing seems to work. I've tried every combination I can think of but get some variation of 'cannot open database' or 'login failed'. Where am I going wrong?

The "connection info" (SQL Server 2008) given by my hosting site is "sql11.sqlsvr.net". I have verified that the user id and password are correct.

Using:
<add name="HostingConnectionString" connectionString="Data Source=sql11.sqlsvr.net;Database=App_Data\ASPNETDB.MDF;User id=administrator1 password=mypassword;Trusted_Connection=False;"
providerName="System.Data.SqlClient" />


results in

Cannot open database "App_Data\ASPNETDB.MDF" requested by the login. The login failed. Login failed for user 'administrator1'.


with trace (partial):

[SqlException (0x80131904): Cannot open database "App_Data\ASPNETDB.MDF" requested by the login. The login failed.
Login failed for user 'administrator1'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4846887
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +144
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +342
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +221
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +189
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +31
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +433

Any suggestions would be helpful. Thanx.


[Other questions that have come up as I wandered in the connectionstring wilderness:

I have SQLExpress on my home/development computer, and SQL Server (2008) on the hosting site. Do/can they use the same connection strings?

Please explain "AttachDbFilename=" vs "Initial Catalog=" vs "Database="

Some website examples use "User Id=" (which seems work, sort of), while others use "uid" or other variations -- which don't work for me at all. Why? ]

Recommended Answers

All 2 Replies

Please use code tags when posting on daniweb:

[code=language] ...code here

[/code]

Next -- Why are you accessing the MDF file directly? You should probably be accessing the SQL Server via Named Pipes which is a form of network communication. Unless you know why you want to access the MDF then I can almost guarantee you want to use networking. What did your hosting provider tell you?

I have posted a windows form login screen code snippet here:
http://www.daniweb.com/code/snippet1244.html

The concepts apply to ASP.NET they are just implemented a little differently.

>>I have SQLExpress on my home/development computer, and SQL Server (2008) on the hosting site. Do/can they use the same connection strings?
-Probably not. At your hosting provider you are accessing a local file from the looks of it so you will need to change your connection strings around.

Take a look here for more examples of connection strings:
http://www.connectionstrings.com/sql-server-2005

[Sorry for the long delay in responding -- paid employment has begun cutting into my computer time. Thanks for your quick response.]

I don't understand your question. Why shouldn't I be accessing the MDF file directly? It is on the same system as the .aspx files, in the same (or nearby) directory. Furthermore, everything I read on the subject of ASP applications assumes and demonstrates great simplicity in connecting to data sources. SQLExpress connection strings work just fine on my local machine -- I can't believe that just connecting to the database on a server is that much more complicated.

There is no mention of named pipes in any of the ASP literature. I only find it in discussions of SQL Server and Linux. So following your suggestion, I've been exploring the web for 'Named Pipes' -- and the complexity (and my confusion), is exponentially greater. This just cannot be right -- I'm interested in programming, but it shouldn't require an engineering degree to assemble my ASP.Erector Set!

Answering your question: the hosting provider gave me this: "connection info: sql11.sqlsvr.net".

Obviously, I'm confused and perplexed. Where do I go from here. Thanks for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.