Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a textbox that returns a value from a database this value is also my primary key column so i get the value from company which is my primary key i then update the value in the textbox when i press enter i run
C#
("UPDATE t_company SET Company_Name=@Company_Name where Company_Name=@Company_Name",mycon1)

the problem is it doesnt give me any errors but it does not update it in the database but if i change the value of @company to a fixed value
C#
("UPDATE t_company SET Company_Name=@Company_Name where Company_Name='abc'",mycon1)
it then works
any help would be appreciated.
Posted
Updated 9-Oct-12 22:08pm
v2

u should set company primary key too
update query will update which column u specified only
u didn't mentioned the primary key column name to update

("UPDATE t_company SET Company_Id=@Company_Id,Company_Name=@Company_Name where Company_Name=@Company_Name",mycon1)
 
Share this answer
 
Comments
mrDivan 11-Oct-12 4:19am    
Im sorry I dont understand could you give me an example
vasim sajad 11-Oct-12 5:54am    
tell me ur table structure of t_company and which column is primary key ?
mrDivan 11-Oct-12 7:54am    
i have 11 columns and company_name is my primary key
In your previous query you are not updating anything.

See your query
SQL
UPDATE t_company SET Company_Name=@Company_Name where Company_Name=@Company_Name


It means you are updating Company name with the same value. Hence you are not observing change.
 
Share this answer
 
v2
Comments
ridoy 10-Oct-12 4:26am    
right..+5

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