MySQL Forums
Forum List  »  MySQL for Visual Studio

Query with parameters
Posted by: Sergio Botta
Date: August 12, 2019 08:56PM

I use MySql.Data.MySqlClient in VB.NET and MySQL 5. I need to run this query:

qry = "SELECT @rownum1:=@rownum1+1 AS rownum, fld1, fld1 FROM ( SELECT @rownum1:=0 ) r, tablename WHERE fld2='some_value' ORDER BY fld2"
Dim cmd As New MySqlCommand(qry, conbd)
cmd.Parameters.AddWithValue("@rownum1", 0)
Dim dr As MySqlDataReader = cmd.ExecuteReader

but I don't whant that @rownum1 be replaced with 0, because I use it to number rows. If I donĀ“t add parameter to cmd it fails, if I add it, @rownum1 is replaced with parameter passed.

Any idea how to solve this? Thanks a lot!

Options: ReplyQuote

Written By
Query with parameters
August 12, 2019 08:56PM
August 30, 2019 10:55AM
August 30, 2019 12:31PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.