I have query previously was name=N'hook' then was changed to name=@name these changes was made in order to avoid sql injection, I think in the new code is missing the single quotes and the prefix N, but I'm not sure.
//OLD CODE with prefix N, the param is wrapped in single quotes
var schemaName = "";
...
var command = new SqlCommand("SELECT schema_id FROM sys.schemas WHERE name = N'" + schemaName + "')";
//OLD CODE without prefix N, the param is wrapped in single quotes
var schemaName = "";
...
var command = new SqlCommand("SELECT schema_id FROM sys.schemas WHERE name = '" + schemaName + "')";
//NEW CODE
var schemaName = "";
...
var command = new SqlCommand("SELECT schema_id FROM sys.schemas WHERE name = @schemaName");
command.Parameters.Add(new SqlParameter("@schemaName", schemaName));