When pulling data from a Microsoft SQL Server using the DataReader from System.Data.SqlClient, it appears that I can use either Get or GetSql commands (for example GetString or GetSqlString.)
When would I use GetString over GetSqlString? Or the other way around?
I've searched the Microsoft documentation and Stack Overflow, and while I can find examples of how to use either method, I have yet to find a why.
It seems there are some hints it might be something to do with handling null values?
I'm working on creating a Web Api project, and have been reading in strings using the method below, and thought possibly my method had some danger I wasn't aware of, but it seems to handle nulls fine, and am not explicitly using either GetString or GetSqlString, but should I be?
SqlDataReader dr = cmd.ExecuteReader();
while (dr.read())
{
loggedMessages.Add(new LoggedMessage
{
MesssageId = dr["ID"].ToString()
});
}