---
title: "Updating database for specific user"  
description: "Updating database for specific user"  
author: "Aaron Douglas"  
published: 2013-06-19  
updated: 2013-06-19  
canonical: https://www.mindstick.com/forum/1201/updating-database-for-specific-user  
category: "ado.net"  
tags: ["ado.net"]  
reading_time: 1 minute  

---

# Updating database for specific user

Hi Expert, \
I'm trying to updata my [sql database](https://www.mindstick.com/articles/337535/connecting-to-sql-databases-ado-dot-net-essentials) for a specific name, and the following code is not working. Any ideas why?\
Here is what I am doing on the [button click](https://www.mindstick.com/forum/790/form-gets-submiited-twice-on-button-click):\
**string person = listBox2.SelectedItem.ToString();****string memberStatus = "platinum";****string conn = "[Data Source](https://www.mindstick.com/interview/808/what-is-a-data-source)=.;Initial Catalog=myDB;[Integrated Security](https://www.mindstick.com/forum/159040/what-is-the-difference-between-integrated-security-true-and-integrated-security-sspi)=True";****using ([SqlConnection](https://www.mindstick.com/forum/1209/sqlconnection-sqlcommand-sqldatareader-idisposable) [connection](https://www.mindstick.com/articles/13012/what-makes-ethernet-connection-better-than-wifi) = new SqlConnection(conn))****{** **[SqlCommand](https://www.mindstick.com/forum/91/difference-between-sqlcommand-and-sqlcommandbuilder) cmd = new SqlCommand("UPDATE Client Set Role = @Status WHERE Name = @name");** **cmd.CommandType = CommandType.Text;** **cmd.Connection = connection;** **cmd.Parameters.AddWithValue("@Status", memberStatus);** **cmd.Parameters.AddWithValue("@name", person);** **connection.Open();** **cmd.ExecuteNonQuery();** **}**\
When I check the database, the Client's Role has not been updated. And when I debug, the value of person is "System.Data.DataRowView" Why is that? How can i fix it?\

## Replies

### Reply by Sumit Kesarwani

Hi, \
The reason the value is **System.Data.DataRowView** is because you bound your list to a **DataView**. And that's cool. But we need to take that into consideration:\
**string person = ((DataRowView)listBox2.SelectedItem)["Name"] as string;****\**Where Name is the name of the field that contains the person's name. I'm making an assumption that the field is named Name. This will fix your query.\


---

Original Source: https://www.mindstick.com/forum/1201/updating-database-for-specific-user

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
