Question

I've made a simple ASP.NET app for managing a MySQL database. I've been using Visual Studio 2013 and their auto-generated elements such as DetailsView, GridView etc. The app works fine locally (including queries to the MySQL server where my site's hosted), but when I try the app on my webhotel I get the error:

Parameter '?' must be defined

I've been in contact with customer support who claims, that it's not a serverproblem but rather a scriptproblem (in spite of me saying that it works fine locally).

An example from my SqlDataSource in the .aspx page looks like this:

InsertCommand="INSERT INTO categories (overName, categoryID) VALUES (?, ?)"

<InsertParameters>
                <asp:Parameter Name="overName" Type="String" />
                <asp:Parameter Name="categoryID" Type="Int32" />
</InsertParameters>

According to MySQL's own bug-site, this was an issue in earlier versions of the MySQL connector:

http://bugs.mysql.com/bug.php?id=66060

however we're using version 6.8.3. The other seemingly viable solution I've found was

http://blog.tjitjing.com/index.php/2009/05/mysqldatamysqlclientmysqlexception-parameter-id-must-be-defined.html

but to no avail. Also, it seems

Any and all help is much appreciated, because I am at wit's end. Thank you

Was it helpful?

Solution

I think it's this line causing the issues..

InsertCommand="INSERT INTO categories (overName, categoryID) VALUES (?, ?)"

It should be something like..

InsertCommand="INSERT INTO categories (overName, categoryID) VALUES (?overName, ?categoryID)"

I believe you need the fields listed in there. I haven't used MySQL in a few months but that is how I use to do it then and this is how I do it in SQL.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top