Govind Sankar
Active member
- Joined
- May 15, 2020
- Messages
- 42
- Programming Experience
- Beginner
Hi,
I have a sql server database with ID, First Name, Last Name, Phone Number and Address. I have created a wpf application that has a dataset of the database and uses a datagrid view to view the table. I did this as a learning procedure. Now I am learning how to update the database using wpf application in Visual Studio. I learned how to update one value which is phone number. I use a table adapter to update the phone number using first name with a button. When u press the button it updates the database.
Update is the button when clicked this happens which is get the first name and then use it to update the phone number using the table adapter which has the sql query
This part worked. But now what I am trying to do is update any value that is update First Name, Last Name, Phone Number or Address using ID and by just using one button and one table adapter. Is this possible or do I have to create seperate buttons and seperate table adapters for each column. Thank you.
I have a sql server database with ID, First Name, Last Name, Phone Number and Address. I have created a wpf application that has a dataset of the database and uses a datagrid view to view the table. I did this as a learning procedure. Now I am learning how to update the database using wpf application in Visual Studio. I learned how to update one value which is phone number. I use a table adapter to update the phone number using first name with a button. When u press the button it updates the database.
C#:
private void Update_Click(object sender, RoutedEventArgs e)
{
string FirstName = FN1_Name.Text;
string NewPhoneNo = Interaction.InputBox("Enter Phone Number", "Update", "");
if (NewPhoneNo != "")
{
friends1TableAdapter.UpdatePhoneNumberQuery(NewPhoneNo, FirstName);
}
}
Update is the button when clicked this happens which is get the first name and then use it to update the phone number using the table adapter which has the sql query
SQL:
Update Friends1
Set [Phone Number] = @Phone_Number
Where ([First Name] = @First_Name)
This part worked. But now what I am trying to do is update any value that is update First Name, Last Name, Phone Number or Address using ID and by just using one button and one table adapter. Is this possible or do I have to create seperate buttons and seperate table adapters for each column. Thank you.
Last edited by a moderator: