forum

Home / DeveloperSection / Forums / The data types text and varchar are incompatible in the equal to operator

The data types text and varchar are incompatible in the equal to operator

Jayden Bell 4034 23-Jan-2014

I have used text as a datatype for device name. while adding the data into the form, it throws an error : The data types text and varchar are incompatible in the equal to operator

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);
}


c# c# 
Updated on 23-Jan-2014

Can you answer this question?


Answer

1 Answers

Liked By