From: Reggie Burnett Date: September 26 2004 7:08am Subject: RE: Return parameter from query. List-Archive: http://lists.mysql.com/dotnet/8 Message-Id: <000a01c4a397$a6f5c3d0$7200a8c0@pokey> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Out, intout, and return parameters are only supported when dealing with stored procedures in 5.0 and later. For what you are doing, you should not use a parameter. See this code. MySqlCommmand cmd =3D new MySqlCommand("SELECT MAX(ID) FROM myTable", conn); Object max =3D cmd.ExecuteScalar(); HTH, Reggie -----Original Message----- From: Asbj=F8rn Konstad [mailto:asbjorn@stripped]=20 Sent: Friday, September 24, 2004 3:06 AM To: dotnet@stripped Subject: Return parameter from query. Hi. =20 Anyone as frustrated as me??? =20 Problem: I have a created a command to return maximum id from myTable.., like this: =20 //---------------------------------------------------------------------- ---- ------------------------------------------------------------------------ ---- ----- =20 MySqlCommand cmd =3D new MySqlCommand(=93SELECT @PAR :=3D MAX(ID) FROM myTable=94, myConnection); MySqlParameter param =3D new MySqlParameter(); param =3D cmd.Parameters.Add(=93@PAR=94, MySqlDbType.Int32, 4); param.Direction =3D ParameterDirection.Output; =20 myConnection.Open(); cmd.ExecuteNonQuery(); int max_id =3D (int)cmd.Parameters[=93@PAR=94].Value; myConnection.Close(); =20 //---------------------------------------------------------------------- ---- ------------------------------------------------------------------------ ---- ---- =20 This gives me an error -> =93error in SQL-Syntax=94. I read the issue with use of =93?=94 instead of =93@=94, and I=92ve = tried it all=85=85!, it keeps throwing exeptions like =93null values=94=20 =93Object reference not set to an instance of an object=94=85 and so on. =20 Anyone have a fail-proof method of creating a command with return-parameters?? =20 Thanks. =20 Reg. =20 Asbj=F8rn Konstad --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.768 / Virus Database: 515 - Release Date: 22.09.2004 =20