I'm querying a SQL server database using the following code, and getting some unexpected results back. Some of my characters are getting converted to '?' characters. The code I am using to query is:
var theConnectionString = @"Data Source=my-sql-server;Initial Catalog=My_Database;Integrated Security=True";
var theQuery = @"select '❤' as panda";
var dataSet = new DataSet();
using (SqlConnection connection = new SqlConnection(theConnectionString))
{
connection.Open();
var command = new SqlCommand(theQuery, connection);
foreach (var param in parameters.Keys)
{
command.Parameters.AddWithValue(param, parameters[param]);
}
SqlDataAdapter adapter = new SqlDataAdapter(command);
adapter.Fill(dataSet);
}
return dataSet;
This results in a dataset of 1 column with 1 row, with a value of '?' (character code ), instead of 10084.
Interactive debugging shows me that the values are correctly encoded in theQuery
though.