"SELECT guid" + "FROM trafficScotland" + "WHERE guid ="
It:
SELECT guidFROM trafficScotlandWHERE guid =
In any case, it makes no sense to break it into separate lines, but you do not have enough spaces between words :)
string resultGuidAsString = null;
string cmdQuery = "SELECT guid FROM trafficScotland WHERE guid=@guid";
SqlCommand myCmd = new SqlCommand(cmdQuery, myConnection);
myCmd.Parameters.AddWithValue("@guid", guid1);
object result = myCmd.ExecuteScalar();
if (result != DBNull.Value && result != null)
{
resultGuidAsString = result.ToString();
}
^^ Here is an improved version. A few points for criticism if I can:
- No parameters were used for your request: just building one line. Risk of safety, readability and maintainability.
- , , , , ,
DBNull.Value, - -
string, Guid s. .