This is not going to work.  If you are using MySQLCommandBuilder, then the
auto-generated ID will be pulled back for you (basically because it does a
select last_insert_id() internally).  Or you can issue a select
last_insert_id() manually to determine the last generated id.

> -----Original Message-----
> From: Colin Shreffler [mailto:[EMAIL PROTECTED]
> Sent: Sunday, December 04, 2005 4:30 AM
> To: mysql@lists.mysql.com
> Subject: .NET Connector Output Values
> 
> I have the following code:
> 
> ...
> query = "INSERT INTO a_test_table
> (a_test_table_id,name,last_mod_date,create_date) VALUES
> (?a_test_table_id,?name,?last_mod_date,?create_date)";
> ...
> command.Prepare();
> ...
> command.Parameters.Add("?a_test_table_id", MySqlDbType.Int32);
> command.Parameters["?a_test_table_id"].Direction =
> ParameterDirection.Output;
> command.Parameters.Add("?name", this._name);
> command.Parameters.Add("?last_mod_date", DateTime.Now);
> command.Parameters.Add("?create_date", DateTime.Now);
> 
> command.ExecuteNonQuery();
> 
> this.ID =
> System.Convert.ToInt32(command.Parameters["?a_test_table_id"].Value.ToStri
> ng());
> 
> When I try to retrieve the return value for ?a_test_table_id, I get an
> error saying the Value property is NULL.
> 
> The column in the database is set to auto-increment.  Shouldn't this
> parameter be populated automatically?  Any ideas why this is happening?
> 
> 
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to