From: David Anderson
Date: September 16 2004 5:07pm
Subject: Bug with parameters?
List-Archive: http://lists.mysql.com/dotnet/2
Message-Id: <4149C863.1010500@dmaassociates.co.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
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 description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
[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();
}
}
}