Select from following answers:- string commandText = "SELECT * FROM Customers WHERE LastName=@LastName"; SqlCommand cmd = new SqlCommand(commandText, conn); cmd.Parameters.Add("@LastName",txtBoxLastName.Text);

- string commandText = "SELECT * FROM Customers WHERE LastName=@LastName"; SqlCommand cmd = new SqlCommand(commandText, conn); cmd.Parameters.Add("@LastName");
- string commandText = "SELECT * FROM Customers WHERE LastName='{0}'"; SqlCommand cmd = new SqlCommand(commandText, conn); cmd.Parameters.Add("0", txtBoxLastName.Text)
- All Above
When you add a parameter to the SqlCommand.Parameters collection, you must give it a name prefixed with "@". This name must match the parameter name given in the command string.
You must provide a parameter value when adding the parameter with the Add method.
Show Correct Answer
Source: MeasureUp.Com | |
Alert Moderator