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;
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();".
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With