Parameter '@myLeft' must be defined

后端 未结 4 1726
南方客
南方客 2020-12-17 14:47

My question is quite similar to already answered ones but yet not. I\'d like some help sorting this out.

I\'m trying to add data to a database table but I get keepin

相关标签:
4条回答
  • 2020-12-17 15:14

    I found the solution to this problem by making an extensive Google search for undefined parameters in MySQL. This article (MySql.Data.MySqlClient.MySqlException: Parameter ‘@id’ must be defined) covers the basics of the problem. It's as far as I understand related to an upgrade of the connector.

    You need to add Allow User Variables=True in the connection string in order to use custom variables. Pretty simple solution to an equally tough problem. ;)

    0 讨论(0)
  • 2020-12-17 15:24

    The error is very much informative, you are just using @myLeft parameter in your query without defining it. you ned to define that parameter like the others you have done.

    objCmdInsert.Parameters.Add("?myLeft",...
    
    0 讨论(0)
  • 2020-12-17 15:25

    Can you try:

    objCmdInsert.Parameters.Add("@myLeft", MySqlDbType.Int).Value = 1212;
    

    You probably have to do it for EACH occurrence of that parameter.

    It's not clear to me what's the meaning of SET @myLeft := lft; (You are trying to assign column value to parameter)

    0 讨论(0)
  • 2020-12-17 15:26

    Before using @myLeft, you need to declare it. For example, assuming @myLeft is an INT:

    DECLARE @myLeft INT;
    
    0 讨论(0)
提交回复
热议问题