---
title: "Conversion failed when converting the nvarchar value 'meetingId' to data type int"  
description: "Conversion failed when converting the nvarchar value 'meetingId' to data type int"  
author: "Anonymous User"  
published: 2015-04-15  
updated: 2015-04-15  
canonical: https://www.mindstick.com/forum/23101/conversion-failed-when-converting-the-nvarchar-value-meetingid-to-data-type-int  
category: ".net"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Conversion failed when converting the nvarchar value 'meetingId' to data type int

I have a [dropdownlist](https://www.mindstick.com/articles/324837/how-to-bind-dropdownlist-in-mvc-core-from-database-using-entity-framework) and I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to insert the [DataValueField](https://www.mindstick.com/forum/12846/dropdownlist-datavaluefield-in-asp-dot-net-c-sharp) into a [database table](https://www.mindstick.com/forum/159366/how-to-test-regular-expressions-in-sql-without-using-database-table). The DataValueField is retrieved from the database and the data type for the column is INT. However, when the run the query I get this [error message](https://www.mindstick.com/forum/23174/error-message-the-page-you-are-requesting-cannot-be-served-because-of-the-extension-configuration)

[Conversion](https://www.mindstick.com/forum/1734/conversion-from-32-bit-integer-to-4-chars) failed when converting the nvarchar value 'meetingId' to data type int.

## Code:

```
if (MinuteUpload.HasFile){    string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;     string updateSql = "UPDATE Project_Meeting SET meetingMinute = @meetingMinute WHERE meetingId = @MeetingId"; ;     using (SqlConnection myConnection = new SqlConnection(connectionString))    {        myConnection.Open();         SqlCommand myCommand = new SqlCommand(updateSql, myConnection);         myCommand.Parameters.AddWithValue("@meetingMinute", "postUpload/" + filename);        myCommand.Parameters.AddWithValue("@MeetingId", MinuteDropDown.DataValueField);         myCommand.ExecuteNonQuery();         myConnection.Close();    }}
```

However, when I try

Convert.ToIint.TryParse16(MinuteDropDown.DataValueField.Trim())

I get this error:

Input [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) was not in a [correct format](https://www.mindstick.com/forum/72/input-string-was-not-in-a-correct-format).

## Replies

### Reply by Elena Glibart

myCommand.Parameters.AddWithValue("@MeetingId", MinuteDropDown.DataValueField);

There are two things wrong. First, DataValueField represents the name of the property, not the value of the property. SelectedValue is what you want.

But once you make that change, SelectedValue is still a string. You should parse that into an int in advance, before adding your parameter:

```
int meetingId = int.Parse(MinuteDropDown.SelectedValue);myCommand.Parameters.AddWithValue("@MeetingId",meetingId);
```


---

Original Source: https://www.mindstick.com/forum/23101/conversion-failed-when-converting-the-nvarchar-value-meetingid-to-data-type-int

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
