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. C#
  4. Retrieve all rows in MySQL stored procedure and put in in C# class.

Retrieve all rows in MySQL stored procedure and put in in C# class.

Scheduled Pinned Locked Moved C#
databasequestioncsharpmysqltutorial
3 Posts 3 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.
  • D Offline
    D Offline
    dudz artiaga
    wrote on last edited by
    #1

    Hi everyone! My C# Project is using MySQL stored procedure to execute sql query. My question is How will I retrieve all rows in select * statement and put in a class? For example. [Row column]..........[Class 'User' member] user_name -----> userName user_id ---------> userID I do not have idea at all since I am new to this C# and MySQL tandem. Thank you in advance.

    S S 2 Replies Last reply
    0
    • D dudz artiaga

      Hi everyone! My C# Project is using MySQL stored procedure to execute sql query. My question is How will I retrieve all rows in select * statement and put in a class? For example. [Row column]..........[Class 'User' member] user_name -----> userName user_id ---------> userID I do not have idea at all since I am new to this C# and MySQL tandem. Thank you in advance.

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      I would have a read through these, it shows you how to call a stored procedure from MySQL Calling a stored procedure from MySQL in C#[^] http://dev.mysql.com/doc/refman/5.0/en/connector-net-programming-stored.html[^]

      Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

      1 Reply Last reply
      0
      • D dudz artiaga

        Hi everyone! My C# Project is using MySQL stored procedure to execute sql query. My question is How will I retrieve all rows in select * statement and put in a class? For example. [Row column]..........[Class 'User' member] user_name -----> userName user_id ---------> userID I do not have idea at all since I am new to this C# and MySQL tandem. Thank you in advance.

        S Offline
        S Offline
        SaqibRasheed
        wrote on last edited by
        #3

        MySqlCommand cmd = new MySqlCommand("ProcName", new MySqlConnection("ConnectoinStringHere")); // ProcName should be the name of the procedure which you want to call cmd.CommandType = CommandType.StoredProcedure; cmd.Connection.Open(); MySqlDataReader dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection); // Now you have all the data in the dataReader. So, you can loop through the datareader like while (dataReader.Read()) { string name = dataReader["Name"].ToString(); // this will store the Name (which is a column_name in the database) to a local variable } dr.Close(); But it is suggested to not get the full data of a table into the memory unless you really require it.

        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