I feel like this is really simple but after googling for days I cant figure it out.
I'm trying to select from an SQL DB, and use variables in the select statement.
But Parameters.Addwithvalue();
won't work for a table column that has a space in it.
In SQL i need to add [] but it won't work in C#.
This for example does work, as it should, pretty straight forward
cmd.Parameters.AddWithValue(@"fullName", string.Format("{0}", "%" + userName.TrimStart() + "%"));
But this won't work
cmd.Parameters.AddWithValue(@"glboal_country_Travel", string.Format("{0}{1}", "[" + glboal_country.TrimStart(), " Travel]"));
I have tried diffrent variations but nothing works, nor does Parameters.Add(...)
and no i can't change the DB column names for
Any help is appreciated, thank you.
Full SQL command
@"select [AD ID], DISPLAYNAME, Categorisation, @glboal_country from [...db].[dbo].[...View] where [AD ID] = @AD_ID or DISPLAYNAME like @fullName"