locked
Update Statement RRS feed

  • Question

  • User-797751191 posted

    Hi

       In below code i am getting error - A local variable con,trans cannot be declared in this Scope.

    SqlCommand cmd = new SqlCommand("Update [Test] SET [Attachment] = (Select [Attachment] from tbl_Test1 where [No] = @No"), con , trans);

    Thanks

    Sunday, July 7, 2019 2:37 PM

All replies

  • User71929859 posted

    A local variable con,trans cannot be declared in this Scope.

    You are having the double quote before the closing bracket of the SQL statement. Try like below

    SqlCommand cmd = new SqlCommand("Update [Test] SET [Attachment] = (Select [Attachment] from tbl_Test1 where [No] = @No)", con, trans);
    Sunday, July 7, 2019 11:58 PM