Click here to Skip to main content
14,640,678 members
Rate this:
Please Sign up or sign in to vote.
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
("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
("UPDATE t_company SET Company_Name=@Company_Name where Company_Name='abc'",mycon1)
it then works
any help would be appreciated.
Updated 9-Oct-12 22:08pm
Rate this:
Please Sign up or sign in to vote.

Solution 1

In your previous query you are not updating anything.

See your query
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.
ridoy 10-Oct-12 4:26am
Rate this:
Please Sign up or sign in to vote.

Solution 2

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)
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

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100