Link to home
Start Free TrialLog in
Avatar of rp
rpFlag for Portugal

asked on

asp,net vb.net update command parameters

When i use an sql command to update a table with parameters like:

"update product set name=@name ....

Watt is the difference between:
       cmd.Parameters.Add("@name", SqlDbType.VarChar, 60)
       cmd.Parameters("@name").Value = TxtMatricula.Text

and:

        cmd.Parameters.AddWithValue("@neme", Trim(Txtname.Text))
Avatar of mfhorizon
mfhorizon

cmd.Parameters.Add("@name", SqlDbType.VarChar, 60) normally uses when your command is refering to a stored procedures, so you are adding a parameter object to you command

However cmd.Parameters("@name").Value = TxtMatricula.Text you are setting the value of the parameter as what is input in TxtMatricula.Text.

Unless you create a variable (parameter) how can you add value to add... it's that simple...
ASKER CERTIFIED SOLUTION
Avatar of NazoUK
NazoUK
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, NazoUK seems to present my example in a theoritical way as well...
Not really, he wanted to know how using AddWithValue was different. You didn't address this point at all.
Yes, i overlooked last statement of the question, however i answered first 2 perfect.