I am using this code to check whether a value (guid1) already exists in the ‘guid’ table:
string selectString = "SELECT guid" + "FROM trafficScotland" + "WHERE guid = " + guid1;
SqlCommand myCommand = new SqlCommand(selectString, myConnection);
String strResult = String.Empty;
strResult = (String)myCommand.ExecuteScalar();
if (strResult.Length == 0)
But at the
strResult = (String)myCommand.ExecuteScalar();
line, I get the sqlException error
Incorrent syntax near ‘guid’
Please show me what is wrong here?
selectString = "SELECT guid " + "FROM trafficScotland" + " WHERE guid = '" + guid1 +"'";Notice space after guid