title: Properly check if a record already exists in a database
body: <p>I have read other questions on this, but it does not help for the most part.
  Trying to check if a file has already been uploaded(filename is sent to this table) before creating another record and allowing them to upload the same file again. </p>
  
  <p>I am using this code and it keeps telling me every file is a new file, even when I use the same file for testing. Obviously it should result in "Exists". Connection is already established using "this.Master.Conn" so please no SQLCommand stuff.</p>
  
  <p>I even tried using wildcards in the query.</p>
  
  <pre><code>   private string SQLCheck(string FileName)
  {
      string Check = "Select VideoURL from TrainingVideo2 where VideoURL Like '" + FileName +"' and Status=1;";
  
      Object ob = this.Master.Conn.ExecuteSqlScalarCommand(Check);
      string Result;
      if (DBNull.Value.Equals(ob))
      {
          Result = "Exists";
      }
      else
      {
          Result = "NewFile";
      }
      return Result;
  }
  </code></pre>
  
  <p>Also, does anybody have a better(more efficient) way of doing this?</p>
  
  <p>Trying to basically rewrite this in c#.</p>
  
  <pre><code>    Private Function CheckName(name As String) As Int32
      Dim sql As String = "SELECT ID FROM Company Where Name Like '" &amp; name &amp; "' "
      Dim ob As Object = Conn.ExecuteSqlScalarCommand(sql)
      If IsDBNull(ob) Then
          Return 0
      Else
          Return CInt(ob)
      End If
  End Function
  </code></pre>