From: Asbjørn Konstad Date: September 24 2004 8:05am Subject: Return parameter from query. List-Archive: http://lists.mysql.com/dotnet/6 Message-Id: <20040924081013.7171F3DF8@mail.broadpark.no> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0000_01C4A21E.07DE8A40" ------=_NextPart_000_0000_01C4A21E.07DE8A40 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 ------=_NextPart_000_0000_01C4A21E.07DE8A40--