output parameters - once again...
Posted: Thu 08 Sep 2005 21:06
Hi All,
Here is the attempted code - obviously, I want to get the last insert id in one trip and stick it into this._lastinputid class member and to the test_id field of my dataset:
...
this.mySqlInsertCommand1.CommandText = "INSERT INTO cms.test(test_id, testtext) VALUES (\\, :testtext);SELECT :param=@@identity";
...
this.mySqlInsertCommand1.Parameters.Add(new CoreLab.MySql.MySqlParameter("testtext", CoreLab.MySql.MySqlType.VarChar, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "testtext", System.Data.DataRowVersion.Current, null));
this.mySqlInsertCommand1.Parameters.Add(new CoreLab.MySql.MySqlParameter("param", CoreLab.MySql.MySqlType.Int, 11, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "test_id", System.Data.DataRowVersion.Current, this._lastinsertid));
According to the reference, the value of parameter this._lastinsertid 'is set on the completion of the command'. By itself, SELECT @@IDENTITY works perfectly, however I can' t pull the value into the :param and subsequently into the this._lastinsertid. Any ideas?
Thank you.
Here is the attempted code - obviously, I want to get the last insert id in one trip and stick it into this._lastinputid class member and to the test_id field of my dataset:
...
this.mySqlInsertCommand1.CommandText = "INSERT INTO cms.test(test_id, testtext) VALUES (\\, :testtext);SELECT :param=@@identity";
...
this.mySqlInsertCommand1.Parameters.Add(new CoreLab.MySql.MySqlParameter("testtext", CoreLab.MySql.MySqlType.VarChar, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "testtext", System.Data.DataRowVersion.Current, null));
this.mySqlInsertCommand1.Parameters.Add(new CoreLab.MySql.MySqlParameter("param", CoreLab.MySql.MySqlType.Int, 11, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "test_id", System.Data.DataRowVersion.Current, this._lastinsertid));
According to the reference, the value of parameter this._lastinsertid 'is set on the completion of the command'. By itself, SELECT @@IDENTITY works perfectly, however I can' t pull the value into the :param and subsequently into the this._lastinsertid. Any ideas?
Thank you.