No one seems to know how...
-
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:
-
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:
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.
-
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.
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
-
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
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