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. Number of Records in A Dataset

Number of Records in A Dataset

Scheduled Pinned Locked Moved Database
questioncsharpdatabase
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.
  • C Offline
    C Offline
    cybersurferdev
    wrote on last edited by
    #1

    I have successfully retrieved data with an adapter to create my required dataset. But now I want to know how many rows are in my dataset? I am using SQL 2003 and .NET1. I see that many people use the Tables.Rows.Count, but mine isn't working when I do that. How do I retrieve the number of rows of the table in the dataset? Thanks.

    D 1 Reply Last reply
    0
    • C cybersurferdev

      I have successfully retrieved data with an adapter to create my required dataset. But now I want to know how many rows are in my dataset? I am using SQL 2003 and .NET1. I see that many people use the Tables.Rows.Count, but mine isn't working when I do that. How do I retrieve the number of rows of the table in the dataset? Thanks.

      D Offline
      D Offline
      dansoft
      wrote on last edited by
      #2

      please try the following code dim ds as new dataset dim da as new sqldataadapter(strQuery,conn) da.fill(ds,"test") response.write(ds.tables("test").rows.count) strQuery is the select command, conn is the connection

      C 1 Reply Last reply
      0
      • D dansoft

        please try the following code dim ds as new dataset dim da as new sqldataadapter(strQuery,conn) da.fill(ds,"test") response.write(ds.tables("test").rows.count) strQuery is the select command, conn is the connection

        C Offline
        C Offline
        cybersurferdev
        wrote on last edited by
        #3

        I don't know VB I'm using C#. Are you still able to help me in finding out how many records are in a table in a dataset.

        L X 2 Replies Last reply
        0
        • C cybersurferdev

          I don't know VB I'm using C#. Are you still able to help me in finding out how many records are in a table in a dataset.

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

          cybersurferdev wrote:

          I'm using C#.

          Your question should post in C# Forum.[^] But anyway, i still help you with this issue. Try to check this website[^] in order to convert the code from the previous post in order to answer your question.

          1 Reply Last reply
          0
          • C cybersurferdev

            I don't know VB I'm using C#. Are you still able to help me in finding out how many records are in a table in a dataset.

            X Offline
            X Offline
            xvaughan
            wrote on last edited by
            #5

            //this should answer your question string connStr = "Fill in your connection string here"; string sqlStr = "SELECT * FROM someTable"; System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connStr); System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(sqlStr, conn); System.Data.DataSet ds1 = new DataSet("test"); System.Data.DataTable dt1 = ds1.Tables["someTable"]; int rowCount = dt1.Rows.Count; //or a good use is for(int i=0; i< dt1.Rows.Count; i++) { //do something } //or another foreach (System.Data.DataRow dr1 in dt1.Rows) { //Do something else }

            C 1 Reply Last reply
            0
            • X xvaughan

              //this should answer your question string connStr = "Fill in your connection string here"; string sqlStr = "SELECT * FROM someTable"; System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connStr); System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(sqlStr, conn); System.Data.DataSet ds1 = new DataSet("test"); System.Data.DataTable dt1 = ds1.Tables["someTable"]; int rowCount = dt1.Rows.Count; //or a good use is for(int i=0; i< dt1.Rows.Count; i++) { //do something } //or another foreach (System.Data.DataRow dr1 in dt1.Rows) { //Do something else }

              C Offline
              C Offline
              cybersurferdev
              wrote on last edited by
              #6

              Thanks xvaughan

              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