Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Every Buddy

I Can insert with parameters Like this :


C#
Com.Commandtext = "Insert Into Personels VALUES(@ID_Per)"
Com.Parameters.AddWithValue("ID_per" , Txt_ID_per.text)
com.ExecuteNonQuery()


How Can i DO it in UPDATE ?
Posted
Updated 10-Nov-11 1:09am
v2

Exactly the same way

C#
Com.Commandtext = "UPDATE Personels SET field1 = @field1 WHERE ID_per = @ID_per"
Com.Parameters.AddWithValue("ID_per" , Txt_ID_per.text)
Com.Parameters.AddWithValue("field1" , field1Value)
com.ExecuteNonQuery()


Hope this helps
 
Share this answer
 
Comments
Sander Rossel 10-Nov-11 7:18am    
Simple and correct. My 5.
Wayne Gaylard 10-Nov-11 7:31am    
Thanks
VB
Com.Commandtext = "update Personels set fieldname = " & @x & " where ID_Per = " & @ID_Per


where fieldname is the column name you need to update, x is the value to enter and ID_Per is the ID of the record you need to modify

if x is numeric use " & cstr(@x) & "
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900