locked
The data types text and nvarchar are incompatible in the equal to operator. RRS feed

  • Question

  • Hi all,

    I really dont know where a mistake in my code ...

    using (SqlCommand cmd = new SqlCommand("SELECT * FROM mac_adresa WHERE mac = @mac;", con))
    {
        string mac = GetMACAddress();
        cmd.Parameters.AddWithValue("@mac", mac);
        SqlDataReader dr = cmd.ExecuteReader();
    ...

    and error message is in title: The data types text and nvarchar are incompatible in the equal to operator.

    Please help.

    Friday, October 9, 2020 11:10 AM

Answers

  • If mac column data type is "text" (which you can not indexed), do you really need that much storage for your data or can you change to nvarchar(max).



    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by TakeshiKitano Friday, October 9, 2020 11:48 AM
    Friday, October 9, 2020 11:36 AM

All replies