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. Web Development
  3. No one seems to know how...

No one seems to know how...

Scheduled Pinned Locked Moved Web Development
htmldatabasewcfquestion
4 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.
  • R Offline
    R Offline
    Robby
    wrote on last edited by
    #1

    I'm trying to do something that is even stumping the web services guys at the company I work. I know it's simple, just can't figure out the syntax! It's also very difficult to explain, so here goes: I am wanting to SELECT * from a table, and then iterate through each record in the RS, defining each record as a variable with only a few lines of code. For instance, instead of this: lastName = RS("lastName") I want to do something like this (I know this syntax is erroneous, only way to explain): For each Field in RS [Field.Name.in.RS] = [Field.Value.in.RS] Next So, theoretically, when the cursor reaches 'lastName' in the RS, it will create a variable called lastName and assign the value of lastName to it. Make sense? I simply want to select and create variables for ALL results from a query without having to manually state them. I know someone will want to know why the heck I want to define all these when I can just plug them in HTML as RS("lastName"), but trust me, I need this! Thanks, Robby:confused:

    R 1 Reply Last reply
    0
    • R Robby

      I'm trying to do something that is even stumping the web services guys at the company I work. I know it's simple, just can't figure out the syntax! It's also very difficult to explain, so here goes: I am wanting to SELECT * from a table, and then iterate through each record in the RS, defining each record as a variable with only a few lines of code. For instance, instead of this: lastName = RS("lastName") I want to do something like this (I know this syntax is erroneous, only way to explain): For each Field in RS [Field.Name.in.RS] = [Field.Value.in.RS] Next So, theoretically, when the cursor reaches 'lastName' in the RS, it will create a variable called lastName and assign the value of lastName to it. Make sense? I simply want to select and create variables for ALL results from a query without having to manually state them. I know someone will want to know why the heck I want to define all these when I can just plug them in HTML as RS("lastName"), but trust me, I need this! Thanks, Robby:confused:

      R Offline
      R Offline
      Roger Wright
      wrote on last edited by
      #2

      Although I haven't tried it, I'd suggest trying this procedure: 1. Select * from the table. 2. Determine the number of records returned, n: n = RS.RecordCount 3. DIM an array(n) for each variable of interest, First(n),Last(n), etc 4. Iterate through the recordset using this sort of construct: i= 0 While Not RS.EOF First(i) = RS.Fields("First") Last(i) = RS.Fields("Last") i = i + 1 RS.MoveNext WEND This should leave you with a pair of matched arrays, one of each per record returned. Large recordsets could be problematic, but this is what I'd try first. "Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.

      R 1 Reply Last reply
      0
      • R Roger Wright

        Although I haven't tried it, I'd suggest trying this procedure: 1. Select * from the table. 2. Determine the number of records returned, n: n = RS.RecordCount 3. DIM an array(n) for each variable of interest, First(n),Last(n), etc 4. Iterate through the recordset using this sort of construct: i= 0 While Not RS.EOF First(i) = RS.Fields("First") Last(i) = RS.Fields("Last") i = i + 1 RS.MoveNext WEND This should leave you with a pair of matched arrays, one of each per record returned. Large recordsets could be problematic, but this is what I'd try first. "Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.

        R Offline
        R Offline
        Robby
        wrote on last edited by
        #3

        Thanks, the problem is that I do not want to define anything because I have so many tables with so many different column values. Basically I just want a 2d array that will have the column name and the value for that column. I am only selecting one row on my select statement, so i want array something like: lastName,doe firstName,john column3,True column4,True column5,True column6,True etc... Anyone? Thanks, Robby

        Richard DeemingR 1 Reply Last reply
        0
        • R Robby

          Thanks, the problem is that I do not want to define anything because I have so many tables with so many different column values. Basically I just want a 2d array that will have the column name and the value for that column. I am only selecting one row on my select statement, so i want array something like: lastName,doe firstName,john column3,True column4,True column5,True column6,True etc... Anyone? Thanks, Robby

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          So basically, something like this?

          Function DumpRow(recordset)
          Dim arrData, index, count
          count = recordset.Fields.Count
          ReDim arrData(count - 1, 1)
          For index = 0 To count - 1
          With recordset.Fields(index)
          arrData(index, 0) = .Name
          arrData(index, 1) = .Value
          End With
          Next
          DumpRow = arrData
          End Function


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          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