title: Conversion failed when converting from a character string to uniqueidentifier. in C# code when I try to insert record by SQL insert statement
body: <p>I have a method in my C# code that insert record in SQL table , I am getting this error right when I execute insert query:</p>
  
  <p>"Conversion failed when converting from a character string to uniqueidentifier."</p>
  
  <p>This is line I have in my C# code that produce error AgencyId and User are both uniqueidentifier in SQl table. </p>
  
  <pre><code>db.AddInParameter(command, Agency, DbType.String, dto.AgencyId);
  
  db.AddInParameter(command, User, DbType.String, dto.User);
  </code></pre>
  
  <p>This is my insert Stored proc:</p>
  
  <pre><code>     ALTER PROCEDURE [dbo].[insert_ApplicantLoan]
          @RemRef              varchar(15)    = null
         ,@Agency              varchar(100)   = null /* uniqueidentifier */
         ,@User                varchar(100)   = null /* uniqueidentifier */
  
  
  
  AS
  BEGIN
  
  
      INSERT INTO [dbo].[ApplicantLoan]
             ( 
              [RemRef]
             ,[_Agency]
             ,[_User]
            )
       VALUES
             (  
              @RemRef               
             ,@Agency              
             ,@User)
  
          Set @Id =  SCOPE_IDENTITY() 
  
  
  
          Select @Id
      End
  
  
  
  END
  </code></pre>