This is a migrated thread and some comments may be shown as answers.

SQL connection error while running demo

8 Answers 516 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 02 Nov 2009, 03:50 PM
I am getting error as below:
It was working fine last week until I reinstalled. Any suggestion?

 

Server Error in '/RadControls_AspNetAjax' Application.

Cannot open user default database. Login failed.
Login failed for user '***************'.

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: Cannot open user default database. Login failed.
Login failed for user '***********'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SqlException (0x80131904): Cannot open user default database. Login failed.
Login failed for user '*********'.]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849015
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2394
   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
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +499
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +65
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
   System.Data.SqlClient.SqlConnection.Open() +122
   System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +47

8 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 02 Nov 2009, 10:20 PM
Does this occur with every demo that uses a sample SQL connection? Also, were there any issues when you re-installed and have you tried to re-install again? You might need to see if the user you are currently logged in as has the security rights to access the installed demo's database files.
0
Jay
Top achievements
Rank 1
answered on 04 Nov 2009, 05:15 PM
Somehow all files were installed as read-only under Telerik folder. Must be Win-7 problem. Never happened before in same environment, I am using win-7 over 3 months. Changed folder security as well to give write access to data.

Thanks
0
Ziji
Top achievements
Rank 1
answered on 17 Sep 2011, 04:09 PM
I use only SQL SQLExpress 2008 and no SQL Server or SQL Server Dev installed on my Windows 7 laptop.
The account running SQLExpress on my laptop is Network Service.
I had trouble running AJAX Demo as I kept getting above errors for months. I tried many tricks posted here but no luck.
Finally, I tried to grant Full Conctrol to Network Service on 'C:\PROGRAM FILES\TELERIK\RADCONTROLS FOR ASP.NET AJAX Q1 2011\LIVE DEMOS' folder (NOT the App_Data under it !!!) and the Demo works without any database connection error.
The important thing is the folder needs the Full Conctrol permission is LIVE DEMOS, NOT App_Data under it !!!
0
Jorge
Top achievements
Rank 1
answered on 07 Oct 2011, 05:39 PM
I'm having the same trouble. You changed the permissions for which user?

Greetings!
0
Bilal M
Top achievements
Rank 1
answered on 25 Nov 2013, 06:43 PM
Just change your instance name from webconfig e.g.

<add name="NorthwindConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Northwind.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>

TO

<add name="NorthwindConnectionString" connectionString="Data Source=YOURINSTANCENAME;AttachDbFilename=|DataDirectory|Northwind.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>

AND as well

<add name="OlympicsConnectionString" connectionString="Data Source=YOURINSTANCENAME;AttachDbFilename=|DataDirectory|OlympicsReadOnly.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>

    <add name="NorthwindConnectionString35" connectionString="Data Source=YOURINSTANCENAME;AttachDbFilename=|DataDirectory|Northwind.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
   
<add name="TelerikConnectionString35" connectionString="Data Source=YOURINSTANCENAME;AttachDbFilename=|DataDirectory|Telerik.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
   
 <add name="NorthwindEntities" connectionString="metadata=res://*;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=YOURINSTANCENAME;AttachDbFilename=|DataDirectory|\Northwind.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
   
<add name="TelerikEntities" connectionString="metadata=res://*;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=YOURINSTANCENAME;AttachDbFilename=|DataDirectory|\Telerik.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
   
<add name="QSFRatingsConnectionString" connectionString="Data Source=YOURINSTANCENAME;AttachDbFilename=|DataDirectory|QSFRatings.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
   
<add name="SelfReferencingDbConnectionString" connectionString="Data Source=YOURINSTANCENAME;AttachDbFilename=|DataDirectory|TelerikSelfReferencingDb.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
   
<add name="NorthwindEntities35" connectionString="metadata=res://*;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=YOURINSTANCENAME;AttachDbFilename=|DataDirectory|\Northwind.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
   
 <add name="TelerikEntities35" connectionString="metadata=res://*;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.YOURINSTANCENAME;AttachDbFilename=|DataDirectory|\Telerik.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>

*Don't forget to save your original WebConfig file separately
Thanks To SIR RAFIQ. 
0
Bilal M
Top achievements
Rank 1
answered on 28 Mar 2014, 04:53 PM
Remove User Instance = True; in case of SQL sa password is activated
0
Valentin
Top achievements
Rank 1
Iron
answered on 31 Jul 2022, 12:10 PM

Hello, i was trying both solutions , but the error of loading the GRID examples still persist. 

What will you advise me to do next ? 

 

Regards.

Valentin Dragnev

 

David
Top achievements
Rank 1
Iron
commented on 23 Jan 2023, 08:29 AM | edited

Certainly, SQL Server Express is running, right? The typical illustration of a login that is susceptible to SQL injection is to also parameterize your SQL query. According tho thenewsinsides use an enum most likely if you have a variable that will be one of multiple values used to determine what your programme does next. This enables you to name the many possible values and then simply use the names to refer to them (often without supplying the actual integer values because they aren't what's relevant).
0
Valentin Dragnev
Telerik team
answered on 03 Aug 2022, 12:41 PM

Hi guys,

The "Cannot open user default database. Login failed" error is related to demo packet database usage. Basically, it's not necessary to have a SQL server instance installed on your PC and you can run any of the demos with the Visual Studio localDB data source, instead. To fix the error, just change "Data Source" to point to the localDB of the demos as shown below:

Web.config

<add name="NorthwindConnectionString" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|Northwind.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>

<add name="NorthwindReadWriteEntities" connectionString="metadata=res://*/App_Code.Model.ReadWrite.NorthwindReadWriteModel.csdl|res://*/App_Code.Model.ReadWrite.NorthwindReadWriteModel.ssdl|res://*/App_Code.Model.ReadWrite.NorthwindReadWriteModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\Northwind.mdf;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework;user instance=False&quot;" providerName="System.Data.EntityClient"/>

On a side note, I'd like to point out that the "User Instance = True" setting in the solution provided by Bilal M might need to be deleted or set to User Instance="False" for the last four connection strings:

<add name="QSFRatingsConnectionString" connectionString="Data Source=YOURINSTANCENAME;AttachDbFilename=|DataDirectory|QSFRatings.mdf;Integrated Security=True;User Instance=False" providerName="System.Data.SqlClient"/>
   
<add name="SelfReferencingDbConnectionString" connectionString="Data Source=YOURINSTANCENAME;AttachDbFilename=|DataDirectory|TelerikSelfReferencingDb.mdf;Integrated Security=True;User Instance=False" providerName="System.Data.SqlClient"/>
   
<add name="NorthwindEntities35" connectionString="metadata=res://*;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=YOURINSTANCENAME;AttachDbFilename=|DataDirectory|\Northwind.mdf;Integrated Security=True;User Instance=False;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
   
 <add name="TelerikEntities35" connectionString="metadata=res://*;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.YOURINSTANCENAME;AttachDbFilename=|DataDirectory|\Telerik.mdf;Integrated Security=True;User Instance=False;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>

Please test and let us know if you face any other problems.

Regards, Valentin DragnevProgress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
Jay
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Jay
Top achievements
Rank 1
Ziji
Top achievements
Rank 1
Jorge
Top achievements
Rank 1
Bilal M
Top achievements
Rank 1
Valentin
Top achievements
Rank 1
Iron
Valentin Dragnev
Telerik team
Share this question
or