1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Sqldatasource updatecommand error

Discussion in 'ASP' started by Carlos, Jul 15, 2009.

  1. Carlos

    Carlos New Member

    Joined:
    Dec 5, 2008
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    none
    Hi! please see this code it gives runtime error:Must declare the scalar variable "@LastName".


    SqlDataSource datasource1 = new SqlDataSource();
    datasource1.ConnectionString = WebConfigurationManager.ConnectionStrings["connectionstring1"].ConnectionString;


    datasource1.UpdateCommand = "Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName where [EmployeeID]=@EmployeeID";

    datasource1.UpdateParameters.Add("@LastName", "James");
    datasource1.UpdateParameters.Add("@FirstName", "Jimmy");
    datasource1.UpdateParameters.Add("@EmployeeID",TextBox1.Text.ToString() );

    datasource1.Update();


    Please tell me where i am wrong???
     

Share This Page