srini4595
asked on
Update Database table with value selected from Dropdown !
Hi,
I am trying to update a database table field with the value selected from the deopdown list.
I want to save changes to the table with the new value.
How can I achieve this in C#.
Thank you.
I am trying to update a database table field with the value selected from the deopdown list.
I want to save changes to the table with the new value.
How can I achieve this in C#.
Thank you.
ASKER
I don't understand what you say
The SQL needed for updating field <MyField> from table <MyTable> from value <OldValue> to value <NewValue> is:
update MyTable
set Myfield = NewValue
where Myfield = OldValue
The NewValue value should be passed from the dropdown listbox you are referring to.
Hope this helps ...
update MyTable
set Myfield = NewValue
where Myfield = OldValue
The NewValue value should be passed from the dropdown listbox you are referring to.
Hope this helps ...
ASKER
I have a table as :
Name ServerName Active
ABC server1 True
ABC server2 False
ABC server3 False
XYZ server1 False
XYZ server2 False
XYZ server3 True
So in this table i have for one name only one server is active.
if i change the server name in the dropdown, then in table the selected server name should become active true and the rest should be false.
Thank you.
Name ServerName Active
ABC server1 True
ABC server2 False
ABC server3 False
XYZ server1 False
XYZ server2 False
XYZ server3 True
So in this table i have for one name only one server is active.
if i change the server name in the dropdown, then in table the selected server name should become active true and the rest should be false.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How do i get the value selected from dropdown into the Sql query.
cmd4 = new SqlCommand("Update sngConnectionTable set Active='True' where PipelineName='SNG' And ServerName=serverName",con );
where serverName is the one I want from the Dropdown.
Thank you.
cmd4 = new SqlCommand("Update sngConnectionTable set Active='True' where PipelineName='SNG' And ServerName=serverName",con
where serverName is the one I want from the Dropdown.
Thank you.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
... update <table> set <column> = <value> ?!