본문 바로가기
개발언어/MySql

MYSQL in ASP.NET Parameter must be defined

by 엔돌슨 2012. 7. 10.
반응형
This statement was throwing an exception error: “MySql.Data.MySqlClient.MySqlException: Parameter ‘@id’ must be defined”

위와 같은 에러 메시지가 발생하였다. Asp.net 에서 mysql 로 넘버링을 작성하는 도중 사용자변수을 선언 하였지만 위와 같은 에러가 발생하였다.



Finally, I  found that this was indeed a change in the .Net Connector. (I’m not sure what version number but starting from 5.2.0 would be my guess)
Starting from version 5.2.2 of the Connector you should add the Allow User Variables=True Connection String Setting in order to use User Defined Variables in your SQL statements.

 
 

참고사이트 :  http://blog.tjitjing.com/index.php/2009/05/mysqldatamysqlclientmysqlexception-parameter-id-must-be-defined.html 



해결책 : 
1. Mysql dll 버전을 높인다.
Download Connector/Net
http://dev.mysql.com/downloads/connector/net/1.0.html 


2. 쿼리 스트링에서 사용자변수을 활성화 한다.
Database=testdb;Data Source=localhost;User Id=root;Password=hello;Allow User Variables=True

위와 같이 dll 변경과 접속정보을 수정하면 된다.