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. Database & SysAdmin
  3. Database
  4. MYSQL TABLE RECORDS TO ARRAY

MYSQL TABLE RECORDS TO ARRAY

Scheduled Pinned Locked Moved Database
mysqldata-structureshelp
6 Posts 4 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.
  • K Offline
    K Offline
    KipkoechE
    wrote on last edited by
    #1

    am looking for a way i can loop through records in mysql table and place the records in an array ...Kindly help

    A L S 3 Replies Last reply
    0
    • K KipkoechE

      am looking for a way i can loop through records in mysql table and place the records in an array ...Kindly help

      A Offline
      A Offline
      Afzaal Ahmad Zeeshan
      wrote on last edited by
      #2

      Continue it like this,

      1. Get the records from your database, using a SELECT clause.
      2. Save that response into a variable of type array (or a generic list).

      Which language are you actually using? C#, Java, C++, PHP? It depends on which framework and language you're using. The language would allow you to perform such actions on the objects (or the list of the object) that is being returned. Usually results from the database are in a form of an array or list.

      The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

      K 2 Replies Last reply
      0
      • A Afzaal Ahmad Zeeshan

        Continue it like this,

        1. Get the records from your database, using a SELECT clause.
        2. Save that response into a variable of type array (or a generic list).

        Which language are you actually using? C#, Java, C++, PHP? It depends on which framework and language you're using. The language would allow you to perform such actions on the objects (or the list of the object) that is being returned. Usually results from the database are in a form of an array or list.

        The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

        K Offline
        K Offline
        KipkoechE
        wrote on last edited by
        #3

        using Vb.net...am trying to achieve it but cant figure to do it

        1 Reply Last reply
        0
        • A Afzaal Ahmad Zeeshan

          Continue it like this,

          1. Get the records from your database, using a SELECT clause.
          2. Save that response into a variable of type array (or a generic list).

          Which language are you actually using? C#, Java, C++, PHP? It depends on which framework and language you're using. The language would allow you to perform such actions on the objects (or the list of the object) that is being returned. Usually results from the database are in a form of an array or list.

          The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~

          K Offline
          K Offline
          KipkoechE
          wrote on last edited by
          #4

          kindly guide me on this

          1 Reply Last reply
          0
          • K KipkoechE

            am looking for a way i can loop through records in mysql table and place the records in an array ...Kindly help

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

            ..and please stop shouting the subject.

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

            1 Reply Last reply
            0
            • K KipkoechE

              am looking for a way i can loop through records in mysql table and place the records in an array ...Kindly help

              S Offline
              S Offline
              sanket164
              wrote on last edited by
              #6

              public void GetDatainArr()
              {
              string strSQl = "";
              string[] Arr = new string[50];
              strSQl = "select [Id] from [tblname] ";
              DataTable dt = GetDataTable(strSQl); //GetDataTable function
              if (dt.Rows.Count > 0)
              {
              for (int i = 0; i < dt.Rows.Count; i++)
              {
              Arr[i] = Convert.ToString(dt.Rows[i][0]);
              }
              }
              }
              public DataTable GetDataTable(string Sql)
              {
              SqlConnection conn = new SqlConnection("ConnectionString ");
              conn.Open();
              DataTable dt = new DataTable();
              SqlCommand cmd = new SqlCommand(Sql, conn);
              SqlDataAdapter ad = new SqlDataAdapter();
              ad.Fill(dt);
              conn.Close();
              return dt;
              }

              This code in C# so you can Convert this code in vb using this link http://www.developerfusion.com/tools/convert/csharp-to-vb/

              Sanket Gandhi

              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