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

后端 未结 2 1111
栀梦
栀梦 2020-12-11 03:08

this is my code

ProductController.cs

public ActionResult Details(string id)
{
    product productx = productDB.products.Single(pr =&         


        
2条回答
  •  春和景丽
    2020-12-11 03:46

    This problem can to occur then use:

    Exemple

    string sql = "Select * from TB_USER where Name = @Name";
    SqlCommand cmd = new SqlCommand(sql);
    

    This is incompatible:

    cmd.Parameters.Add("@Nome", SqlDbType.Text).Value = nome;
    

    Change for:

    cmd.Parameters.Add("@Nome", SqlDbType.VarChar, 50).Value = nome;
    

提交回复
热议问题