Click here to Skip to main content
15,893,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am writing a query to generate a runtime index column as follows:

SET @rank = 0 ; SELECT @rank:=@rank+1 AS No,firstname from users where unm='abc'

The query is running fine when I copy & paste it to sqlyog editor (I am using mysql)
It shows the correct results.
But when i written same query in .NET code and at the movement below code it showing error. It might be becos of ';'

Dataset ds = new Dataset()<br />
MySqlDataAdapter dAdap = new MySqlDataAdapter(SelectQuery, connection);<br />
dAdap.Fill(ds);


Is there any other solution for that.

Is there any other solution if I want to generate runtime index column and return that column into dataset.

Thanks
sjs
Posted
Updated 13-Apr-11 0:51am
v2
Comments
Sandeep Mewara 13-Apr-11 9:13am    
SET @rank = 0 ; SELECT @rank:=@rank+1 AS No,firstname from users where unm='abc'
How do you assign it to "SelectQuery"?

Hi,
Add this to your connection string:

SQL
allow user variables = true
 
Share this answer
 
Check the Connection String .
 
Share this answer
 
Comments
Sandeep Mewara 13-Apr-11 9:13am    
How can this be an issue?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900