---
title: "The data types text and varchar are incompatible in the equal to operator"  
description: "The data types text and varchar are incompatible in the equal to operator"  
author: "Jayden Bell"  
published: 2014-01-23  
updated: 2014-01-23  
canonical: https://www.mindstick.com/forum/1865/the-data-types-text-and-varchar-are-incompatible-in-the-equal-to-operator  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# The data types text and varchar are incompatible in the equal to operator

I have used [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) as a [datatype](https://www.mindstick.com/forum/160266/explain-the-datatype-data-annotation-and-its-significance-in-data-entry-and-display) for [device](https://www.mindstick.com/blog/149/retriving-network-device-information-in-c-sharp) name. while adding the [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) into the [form](https://www.mindstick.com/forum/6/multi-form-mfc-application), it throws an [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) : The data types text and [varchar](https://www.mindstick.com/forum/161878/what-is-the-difference-between-nvarchar-and-varchar) are incompatible in the equal to [operator](https://www.mindstick.com/blog/144/union-intersection-and-except-operator-in-sql-server)

```
try{    cmd = new SqlCommand("insert into license1 values(@l_id,@customer_id,@d_id,@device_name,@from,@to)", cn);    cmd.Parameters.AddWithValue("@l_id", license_id.Text);    cmd.Parameters.AddWithValue("@customer_id", c_comboBox4.Text);    cmd.Parameters.AddWithValue("@d_id", d_id_comboBox4.Text);    cmd.Parameters.AddWithValue("@device_name", d_name_comboBox5.Text);    cmd.Parameters.AddWithValue("@to", DateTime.Parse(date_to.Text));    cmd.Parameters.AddWithValue("@from", DateTime.Parse(date_from.Text));    cn.Open();    a = cmd.ExecuteNonQuery();    if (a > 0)    {        MessageBox.Show("Data Submitted");    }}catch (Exception ex){    MessageBox.Show(ex.Message);}
```

## Replies

### Reply by Pravesh Singh

Hi Jayden,\

I would try to change this line

cmd.Parameters.Add("@device_name", SqlDbType.Text).Value = d_name_comboBox5.Text;

The AddWithValue treats the string values as a NVarChar datatype and looking at error message a Text type is expected.


---

Original Source: https://www.mindstick.com/forum/1865/the-data-types-text-and-varchar-are-incompatible-in-the-equal-to-operator

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
