I think I'm missing something obvious here. The query executes in SQL server no problem. I've googled around and I found out you can use AddWithValue on the SQL command for the parameter @UserID but the issue is I need to search the database to get it. Below is the error the application is generating :
02:59:10,578 fail: Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HMJJMIDP0K9M", Request id "0HMJJMIDP0K9M:00000002": An unhandled exception was thrown by the application. System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near '@UserID'. Incorrect syntax near '.'. Incorrect syntax near 'VJ'. ```
Here is my code
{
var connString = decryptionService.DecryptFromBase64String(options.Value.ConnectionString);
using var conn = new SqlConnection(connString);
await conn.OpenAsync();
using var command = conn.CreateCommand();
command.CommandText = GetSql(request.ScriptName, request.RecoveryCode);
command.CommandType = CommandType.Text;
await command.ExecuteNonQueryAsync();
return Ok("Done");
}