VS2010 web deploy the connection string argument cannot be null or empty
Asked Answered
L

6

27

Having problems deploying a website to an windows 2008 r2 server running IIS7. I have previously deployed another site to this server. The web deploy is connecting and copying my files to server but I see the following error(s).

1 The 'Connection String' argument cannot be null or empty
2   Web deployment task failed.((20/07/2012 14:19:16) An error occurred when the request was processed on the remote computer.)

(20/07/2012 14:19:16) An error occurred when the request was processed on the remote computer. Could not find a part of the path 'C:\Users\Me\Documents\Visual Studio 2010\Projects\MySite\MySiteClient\obj\Release\AutoScripts\EFDbContext-Deployment_SchemaOnly.sql'.     0   0   MySiteClient

I have verified that the path exists on my local machine.

I have tried publish with out web.config transforms and with using the xdt:transform functions to set the remote server strings.

I have also explicitly set the connection strings for both destination and source database in the Package/Publish SQL tab and am at a loss as to what the problem is.

Any ideas?

Linnealinnean answered 20/7, 2012 at 13:47 Comment(1)
Complete user error. After importing from my Web Config I had two DB entries ApplicationServices and MyAppContext. I was setting the connection string for the first entry Application but not for the MyAppContext Entry. Think I overlooked this because I didn't realise that the connection string input box changed with the selected entry in the database list box. doh.....Linnealinnean
L
44

This was happening right now to me and I managed to isolate the problem... after manually adding a new SQL Server connection string in my Web.config I started experiencing this very error when trying to deploy to the remote server.

When I opened the web deploy Publish profile in Visual Studio 2012 I noticed under the Settings tab that it had set this option: Use this connection string at runtime (update destination Web.config).

Strangely this was setup automatically by VS 2012...

To solve the problem, just uncheck that checkbox and web deploy should start working again.

enter image description here

Leninakan answered 3/6, 2013 at 21:0 Comment(2)
Also, if the above steps don't work: delete the publish profile, then follow the steps above, and that should fix it. Happy coding everyone!Yoon
Thanks, this post helped me a lot and saved my time.Allerus
I
15

In addition to Leniel's answer, in case you are not using SqlClient or Entity Framework Code First and thus do not see the checkbox(es), temporarily set the providerName in your web.config's connection string to System.Data.SqlClient and then go back to your publish settings to uncheck the checkbox(es).

Insurgency answered 25/11, 2013 at 16:54 Comment(5)
Thanks for this, I was using a Windows Azure Storage connection string and I had to do as you said (changing to System.Data.SqlClient then resaving the publish settings) to clear this error.Doublebank
I am using MySql on Azure and I have the providerName="MySQL Data Provider" and still the error appear after deployment. (and no check box appears on deployment Page). Can you assist?Hornpipe
Have you tried changing the providerName to "System.Data.SqlClient" first before opening the deployment page?Insurgency
Thanks for this! Btw, the end result is that your pubxml will change from... <MSDeployParameterValue Include="$(DeployParameterPrefix){Name}-Web.config Connection String" /> ...to... <MSDeployParameterValue Include="$(DeployParameterPrefix){Name}-Web.config Connection String"><UpdateDestWebConfig>False</UpdateDestWebConfig></MSDeployParameterValue>Discountenance
Worked beautifully! Thanks. I am publishing to non-Azure, VPS Server.Cystocele
C
12

I was having the same issue:

2>C:...\Microsoft.Web.Publishing.targets(4270,5): Error : The 'db-Web.config Connection String' argument cannot be null or empty. 2>C:...\Microsoft.Web.Publishing.targets(4270,5): Error : The 'dbAudit-Web.config Connection String' argument cannot be null or empty. 2>C:...\Microsoft.Web.Publishing.targets(4270,5): Error : The 'dbLog-Web.config Connection String' argument cannot be null or empty.

as I was using:

<connectionStrings>
  <add name="db" providerName="MySql.Data" connectionString="server=mysql.gko.local;user=maindk;database=gavekortet;port=3306;password=123456" />
  <add name="dbLog" providerName="MySql.Data" connectionString="server=mysql.gko.local;user=maindk;database=logs;port=3306;password=123456" />
  <add name="dbAudit" providerName="MySql.Data" connectionString="server=mysql.gko.local;user=maindk;database=audit;port=3306;password=123456;pooling=false" />
</connectionStrings>

and as I read here the issue was regarding the publish profile, I then opened the .pubxml file and I've found:

<ItemGroup>
  <MSDeployParameterValue Include="$(DeployParameterPrefix)db-Web.config Connection String" />
  <MSDeployParameterValue Include="$(DeployParameterPrefix)dbAudit-Web.config Connection String" />
  <MSDeployParameterValue Include="$(DeployParameterPrefix)dbLog-Web.config Connection String" />
</ItemGroup>

add <UpdateDestWebConfig>False</UpdateDestWebConfig> to each node, so it will became:

<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)db-Web.config Connection String">
  <UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
<MSDeployParameterValue Include="$(DeployParameterPrefix)dbAudit-Web.config Connection String">
  <UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
<MSDeployParameterValue Include="$(DeployParameterPrefix)dbLog-Web.config Connection String">
  <UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
</ItemGroup>

simply by deleting this entry, everything was again working...

Cockshy answered 2/10, 2014 at 15:59 Comment(0)
E
4

None of the provided solutions helped me.

I finally discovered that in my local Web.config, there was an empty default connection string called LocalMySqlServer (probably put there by the Mysql.Data NuGet package).

After I removed the highlighted line below I was able to successfully publish.

enter image description here

Epicenter answered 23/7, 2016 at 14:48 Comment(2)
Seems after reinstalling all packages it installed an empty connection entry. This was the solution, thanks. ;) I kept looking at the publishing profile, but of course MS errors are rarely helpful. ;)Everard
Man... this finally fixed it here. I kept changing the Web Deploy.pubxml and removing everything related to database but there's was an empty connection string in Web.config. I just deleted this connection string from Web.config and now it finished the publish process successfully.Leninakan
A
0

I had the same problem when i deployed a web application to an Azure web-server. I solved it by creating a new server. On that point i realized that there was another application on that server before. That application used a context-name that was not overritten by the second application so that one kept looking for a connectionstring that was overritten by the second application. I asume clearing your server might solve the problem.

Aggie answered 27/12, 2013 at 19:53 Comment(0)
N
0

I had exactly the same problem - right out of the blue on VS 2017.

Turns out that it was because I was running VS as Administrator. I closed the app down, restarted normally and all was back to normal.

Nehru answered 12/3, 2018 at 15:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.