Reputation: 88
I'm starting with Asp.net MVC. When connect to SQL Server database then error.
This is <connectionStrings>
<add name="SGTSVNDBContext" connectionString="Data Source=DESKTOP-ABKAVRM\SQLEXPRESS;Initial Catalog=SGTSVNDBAUTH_CusCloud;Persist Security Info=True;User ID=sa;Password=;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
This is <appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="DefaultPassword" value="123456" />
<add key="CustomerKey" value="YN8HgQuslP7kHfMeJk0NyHbu1R2IyHo4neUWmIHlffA=" />
<add key="GCM-SENDER-ID" value="86033830857" />
<add key="AUTH-TOKEN" value="AIzaSyB3FLcWcrRlOcu_zyCdl6tMawlvSoX4MeQ" />
<add key="FCM-SENDER-ID" value="122441061332" />
<add key="FCM-SERVER-KEY" value="AAAAHIIOU9Q:APA91bGWrJHwfJKiZsRGs8V62_xhuK9x0AWDNewrEnQiPrsrIpZ2YVYKop4Z44LSdNv_iZcSFmHpQ8YxS-WrTniZ5cZMe5T85PKJzv-CTNjTikwc7rqwoIXU--Ssk84IdmBzM8XcYuBb" />
<!--<add key="BackupPath" value="\\192.168.2.10\SGVN-Server\Scan folder\Phat\" />-->
<add key="BackupPath" value="D:\Mine\SystemGear\SGVN_SGF #07_2015\Project\Sites\WebAPI\Database_Backup\" />
<add key="SqlInstanceName" value="SGSOFT09-V2" />
<add key="BackupDBName" value="SGTSVNDBAUTH_CusCloud" />
<add key="SqlUserName" value="sa" />
<add key="SqlPassword" value="" />
When build project then error as the this
Upvotes: 1
Views: 1199
Reputation: 7
If you are sure the SQL Server is in "mixed mode", and that the password is correct for the "sa" account, I can only suggest it to be that the "sa" user doesn't have access to the named database.
In SQL Management Studio, expand the database branch, then security, then users, and check if the "sa" user appears in the list.
The best way to diagnose this error is to try and connect to the database server using SQL Management studio, logging in AS the user in the connection string. If you can log in, see if you can see your target database in the tree on the left. Try it with SQL Management Studio from the same machine you're code is running and it should give you more information about what's wrong.
Try changing your connection string to the following:
If the connection string is correct then check for the key value of connection string used in entity framework class.
Upvotes: 0
Reputation: 2679
You have no password in your connection string, therefore it is failing to login to the database.
Upvotes: 2