SQL login fails in VS project but not LINQPad application

I'm using the NuGet package to run LINQPad scripts in a Visual Studio project. In the LINQPad application I can add a MSSQL database connection and create a script using that connection which will work fine, but in the project when using LINQPad.Util.Run on the same script there's a connection error: Login failed for user [username].

I can see that the connection information is part of the LINQPad file, so what would cause the SQL authentication to work in the application but fail in the project when using LINQPad.Util.Run? My versions are LINQPad 5 v5.43.00 and LINQPad NuGet package v5.40.0.


  • Do you have the same Windows credentials when calling via Util.Run? LINQPad encrypts the password using DPAPI, which is keyed to the logged in user.

  • In this case we don't have the same Windows credentials - the goal is to take a script created by a user and run it inside a web application that's running under a different identity. Is there a way to modify how the password gets encrypted/decrypted?

  • If you're happy to store the password unencrypted, go to the connection dialog and clear the password from the text box. Then click the Advanced button and type 'password=(password)' into the connection string parameters box.

Sign In or Register to comment.