Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Fatal error encountered during command execution asp.net C#

Fatal error encountered during command execution asp.net C#

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpdatabaseasp-netmysqlhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    ven753
    wrote on last edited by
    #1

    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.

    L 1 Reply Last reply
    0
    • V ven753

      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.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups