I have this code:
con.Open();
cmd = new MySqlCommand(String.Format("SELECT concat(name,'|',lastname) FROM {0} WHERE ID= ?Parname;", ConfigSettings.ReadSetting("my_data")), con);
cmd.Parameters.Add("?Parname", MySqlDbType.VarChar).Value = id_value;
var tokens = ((String)cmd.ExecuteScalar()).Split('|');
name = tokens[0];
lastname = tokens[1];
This is working perfectly when I enter id value and when user is actually in database. But I got null exception when there is no such a user inside the database. I need to make this to write me a unknown user if he is not in the database.
If there’s no user with the given id, the return value of
ExecuteScalarisDBNull.Value: