Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

APP vs Application Name in Connection String

What's the differences between the APP attribute and Application Name attributes in the connection string? Is one just an alias to another one? I can't seem to find any documentations about it.

Also, can I put spaces in the value of the Application Name? e.g. Application Name=foo bar;

like image 503
StarCub Avatar asked Mar 01 '12 22:03

StarCub


People also ask

What is application name in connection string?

Simply include "Application Name=MyAppName;" in the connection string. After that it is also possible to use that value in SQL batches or SPROCs with the command, "SELECT APP_NAME();".

What is the best way to store the connection string in a web application?

The best way to secure the database connection string is to encrypt the value within the configuration file. The application would then load the encrypted value from the config file, decrypt the value, and then use the decrypted value as the connection string to connect to the database.

How do I find the name of my SQL server application?

Use APP_NAME() to Get the Application Name of the Current Session in SQL Server. In SQL Server, you can use the APP_NAME() function to get the application name for the current session. This assumes the application sets that name value.


1 Answers

The answer for your first question is yes, app is just an alias. Documentation is here: http://msdn.microsoft.com/en-gb/library/system.data.sqlclient.sqlconnection.connectionstring.aspx

As for your second question, the same documentation page says that the name can be up to 128 characters and says nothing about excluding spaces. A quick test revealed that spaces are allowed.

like image 186
Miguel Avatar answered Oct 05 '22 23:10

Miguel