Hi,
Why not uploaded the data into db?
Do not show any error.

string City = "Berlin";

            string MyConString = "SERVER=localhost;" +
                "DATABASE=test;" +
                "UID=root;" +
                "PASSWORD=;";
            MySqlConnection connection = new MySqlConnection(MyConString);
            MySqlCommand command = connection.CreateCommand();

            command.CommandText = "insert into city(city) VALUES (@City)";

            command.Parameters.Add(new MySqlParameter("@City", MySqlDbType.VarChar, 40)).Value = City;

            try
            {
                connection.Open();
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                error.Text = "error" + ex.Message;
            }
            finally
            {
                connection.Close();
                error.Text = "OK";
            }

Might be your using named parameters... Are you getting NULL values in the table? Try changing "@" to "?" and see what you get.

thanks, worked.

but what's the difference between "?" and "@" ?

thanks, worked.

but what's the difference between "?" and "@" ?

My understanding is that the "?" represents a place holder that is not named, which means you can represent values like: VALUES (?, ?, ?, ?)... Sql Server does not support "?" placeholders, but uses named parameters: VALUES (@fld1, @fld2, @fld3, @fld4, @fld5)...

When using placeholders, I believe the names are ignored, eg: VALUES (?fld1, ?fld2, etc.) would ignore the text following the "?".

With "?" place holders, you must have them in the correct order or the command will fail or unexpected results could occur. With "@" named parameters, the parameter values will be matched to the fields by name.

I suspect the defined "parameter marker" ("?", or "@") is solely determined by the specific data provider, so you might find a library that allows you to use named parameters ("@") with MySql command parameterization--I just don't know if this is true.

Comments
Excellent!!! That is _exactly_ what I would have said :P
This article has been dead for over six months. Start a new discussion instead.