Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

MySqlCommand + Parameters inside query (no replies)

$
0
0
hi...

I have a problem with MySqlCommand class. Inside my query I use variables to emulate row_number inside groups, so i dont need to assign them in Visual Studio.

But I recieve a runtime error: Parameter '@num' must be defined. As i can understand MySqlCommand tries to find parameter values for all instances that start with @

Is there any possibilty to disable this functionality?

the source look like this:

string Query = @"
set @num = 0;
set @source = '';

select
@num := case when @source = x.Source then @num + 1 else 1 end as row_number,
@source := x.Source as dummy,
x.*
from
(
SELECT I.*
FROM Item I
ORDER BY I.Source
) x
";

using (MySqlCommand cmd = new MySqlCommand(Query, this.MysqlConnection)){
using(MySqlDataReader reader = cmd.ExecuteReader()){
}
}

thanks a lot

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>