The multi-part identifier “TextBox1.Text” could not be bound in C# ASP.NET?

前端 未结 3 1619
孤独总比滥情好
孤独总比滥情好 2020-12-12 04:03

I\'m doing a practice project for training; my handler has specifically forbidden paramaterization and security-oriented coding for now, in the interest of getting the basic

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 04:39

    Use parameters to do this. Otherwise you are wide-open for SQL injection.

    SQLCommand cmd = new SQLCommand();
    cmd.CommandText = "UPDATE ProductInstance SET CustId = @CustID WHERE .... ";
    cmd.Parameters.AddWithValue("@CustID", TextBox1.Text);
    cmd.ExecuteNonQuery();
    

提交回复
热议问题