List:MySQL and .NET« Previous MessageNext Message »
From:David Anderson Date:September 16 2004 5:07pm
Subject:Bug with parameters?
View as plain text  
I have the following bit of code which crashes with error "Column 'id' 
cannot be null" when run with the new connector, but the same thing 
works with the ByteFX . Is this a bug, or am I not calling parameters 
correctly?

Regards
David

using System;
using MySql.Data.MySqlClient;

namespace mytest1
{
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
           
            // Set up a mysql connection using MySql-AB
            string connstr = "Persist Security 
Info=False;database=pnet;server=benden;user id=dbuser;Password=p1nestap";
            MySqlConnection conn = new MySqlConnection(connstr);
            MySqlCommand cmd = new MySqlCommand();
            conn.ConnectionString = connstr;
            conn.Open();
            string cmdstr = "insert into rawreviews (id, review) 
values(@id, @review)";
            cmd.Connection = conn;
            cmd.CommandText = cmdstr;
            cmd.Parameters.Add("id", 4);
            cmd.Parameters.Add("review", "Fourth Review");
            cmd.ExecuteNonQuery();
            conn.Close();
        }
    }
}


Thread
Bug with parameters?David Anderson16 Sep
  • RE: Bug with parameters?Reggie Burnett16 Sep