Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to complete operation. The supplied SqlConnection does not specify an initial catalog or AttachDBFileName

I am trying to create an App Service web app in the Azure Portal and to connect the web app to my local on-premises SQL Server database using the new Hybrid Connection feature.

Created a simple ASP.NET application using Visual Studio 2015 and trying to connect to the SQL server Database which is on on-prem. And modified the connection String as follows

<connectionStrings>
    <add name="DefaultConnection" 
         connectionString="Data Source=PRAVEEN,1433; User ID=sa; Password=my_password;" 
         providerName="System.Data.SqlClient" />
</connectionStrings>

When the application is started its running without any errors as shown in below screenshot1.

But when I try register (enter any record) it throws me with an error as specified in the below Screenshot3....

"https://azure.microsoft.com/en-us/documentation/articles/web-sites-hybrid-connection-connect-on-premises-sql-server/" - this is the documentation to which I'm referring to..

So, can anyone from the other end help me out please...

Screenshot1

ScreenShot2

Screenshot3

Microsoft SQL Server Management Studio screenshot....

Microsoft Sql Server Management Studio

Thank you..

like image 474
praveen gogula Avatar asked Sep 06 '16 14:09

praveen gogula


1 Answers

@Praveen, It is what it says - meaning Initial Catalog is missing in your connection string. It requires the Db name to connect to. You have the servername, SQLUserName, SQLPassword, but missing the DatabaseName it requires. Please change your connection string to include the the DbName as follows

<connectionStrings>
    <add name="DefaultConnection" 
         connectionString="Data Source=YourServerName,1433;Database="YourDbName" UserID=YourId;Password=YourPswd;"
         providerName="System.Data.SqlClient" />
</connectionStrings>

Look at this site to configure your connection string appropriately: http://www.connectionstrings.com/store-connection-string-in-webconfig/

like image 185
Jaya Avatar answered Nov 18 '22 02:11

Jaya