I am facing a problem while retrieving nchar(2) from database and assigning to a char variable in c#. Below are the sample values:
DB value: S C# variable value “S ”
DB value: null C# variable value “\0 ”
I am retrieving with dynamic variable and after assigning it to a char variable, it is throwing an error. Do I need to trim first and remove the escape characters before assigning it to char variable or is there any standard functions to perform the task?
Try this:
You will get an empty string as result, for db’s null values and also for empty strings…