Hi Everyone I need a syntax for update statement LIke this:

cmd.CommandText = "UPDATE tab(tab_id,tab_name) SET tab_name=@tname WHERE tab_id=@tab_id";

this one aint working ,Somebody please help.

I have two textboxes tab_id,tab_name

I have to Update tab_name based on tab_id,...when i Click content of datagridview then I will get the content into textboxes like tab_id ,tab_name will be drawn from the grid to the textboxes.

If I change the values from tab_name and click update button it should update both grid as well as underlying database.

Thanks In advance.

Recommended Answers

All 2 Replies

Hi Everyone I need a syntax for update statement LIke this:

cmd.CommandText = "UPDATE tab(tab_id,tab_name) SET tab_name=@tname WHERE tab_id=@tab_id";

this one aint working ,Somebody please help.

I have two textboxes tab_id,tab_name

I have to Update tab_name based on tab_id,...when i Click content of datagridview then I will get the content into textboxes like tab_id ,tab_name will be drawn from the grid to the textboxes.

If I change the values from tab_name and click update button it should update both grid as well as underlying database.

Thanks In advance.

Firstly, please don't bump your threads...especially with duplicate posts.
Secondly, if you are ever unsure of sql syntax there are great references online such as W3CSchools.
You'll see in the link that the syntax you need is "UPDATE tablename SET column1 = @value1 WHERE column2 = @value2".
Correct your update statement and let us know if you still have problems

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.