Fatal error encountered during command execution asp.net C#
-
Hi i have created one web application and in that i need to read the data from Mysql database and bind to gridview. I have written Mysql query as follows SELECT @row_number:=@row_number+1 AS row_number,Name FROM tablename, (SELECT @row_number:=0) AS r After running in Mysql in database it will and work show the result. But if take same query and execute through C# code below error is coming. An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll but was not handled in user code Additional information: Fatal error encountered during command execution. and i will get Break or continue pop up. If i give continue it will show Parameter '@row_number' must be defined. even i defined like int @row_number = 0; but same error. I need to achieve serial number as shown below ex in database slno name 10102 nama1 2123 name2 5203 name3 result 1 nama1 2 name2 3 name3 how to achieve this. If anybody knows please reply me. Thanks in advance.
-
Hi i have created one web application and in that i need to read the data from Mysql database and bind to gridview. I have written Mysql query as follows SELECT @row_number:=@row_number+1 AS row_number,Name FROM tablename, (SELECT @row_number:=0) AS r After running in Mysql in database it will and work show the result. But if take same query and execute through C# code below error is coming. An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll but was not handled in user code Additional information: Fatal error encountered during command execution. and i will get Break or continue pop up. If i give continue it will show Parameter '@row_number' must be defined. even i defined like int @row_number = 0; but same error. I need to achieve serial number as shown below ex in database slno name 10102 nama1 2123 name2 5203 name3 result 1 nama1 2 name2 3 name3 how to achieve this. If anybody knows please reply me. Thanks in advance.
ven753 wrote:
If i give continue it will show Parameter '@row_number' must be defined.
There's an @-sign in there (declaring a user-variable), so .NET will assume you're declaring a parameter. There's no parameter in the collection with those names, hence the exception. Easiest way out is to create a stored procedure. Wrap your SQL in there, call the sproc from .NET.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]