0

how to call an asp parameter in a sql command exp:

cmd.CommandText = "SELECT name FROM server WHERE code="+TextBox1.Text;

is it correct? .

2

1 Answer 1

6

(tries and fails to suppress a shudder)

 cmd.CommandText =  "SELECT name FROM server WHERE code=@code";
 cmd.Parameters.AddWithValue("code", TextBox1.Text);

otherwise, you are just ripe for SQL injection.

NEVER CONCATENATE USER-INPUT INTO COMMANDS

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.