0

I Have a Query in mysql like this:

select 
  t1.id_invoice_in, t1.paymentcode, t1.personname, t1.amount,
  t2.id_invoice_out, t2.paymentcode, t2.personname, t2.amount  
from (
  select     
    id_invoice_in, paymentcode, personname, amount,
    (@r1 := @r1 + 1) as r1
  from invoice_in 
  join paymenttype pt on pt.id = paymenttype_id 
  join persons p on p.id = person_id
  ,(select @r1 := 0) r
) t1 left join (
  select 
    id_invoice_out, paymentcode, personname, amount,
    (@r2 := @r2 + 1) as r2
  from invoice_out 
  join paymenttype pt on pt.id = paymenttype_id 
  join persons p on p.id = person_id
  ,(select @r2 := 0) r
) t2 on t1.r1 = t2.r2;

Sample SQL Fiddle

That query working fine on phpmyadmin. When i put the query in VB.net like this:

myCMD = New MySqlCommand(strQuery, MysqlConn)
mysqlReader = myCMD.ExecuteReader()

i got the error: "fatal error encountered during command execution" from exception message.

i guess maybe the query containt this symbol '@', so i must write myCMD.Parameters.AddWithValue("@", something else). *correct me if im wrong.

the question is, how vb.net by pass the query without entry myCMD.Parameters.AddWithValue. So vb.net just running the query without must entry '@' value, because no value for '@'.

ed.inside
  • 31
  • 7
  • Perhaps [this](http://stackoverflow.com/questions/4929792/how-to-use-mysql-user-variables-with-ado-net) is related? Try adding `Allow User Variables=true` to your connection string. – Mark Sep 08 '15 at 18:25
  • @Mark, thanks for your info. try adding "allow user variables=true" can solve my problem. – ed.inside Sep 09 '15 at 03:39

0 Answers0