maxpouliot
08-25-2006, 08:15 PM
hi, i wonder if a pro can help me with this
i want to loop through all the fields (this is why i use the * in the following query)
"SELECT * FROM cas WHERE id=814"
This returns 1 result but my table has 152 fields (i know... this is too much!) What i would like is to have some code that makes a variable for each field that i have automatically
for example, if i had a table with 3 fields (field1,field2,field3), normally i could this
field1=rs("field1")
field2=rs("field2")
field3=rs("field3")
but is it possible to automate this step?
the code would have to be like :
loop through all the fields
nameOfTheField = valueOfTheField
end loop
am i clear enough?
-------------
i just solved half of my problem with this code :
Dim rs
SQL="SELECT * FROM cas WHERE id=" & idCas
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open SQL,Conn
intfieldcount = rs.fields.count
For intthisfield = 0 To intfieldcount -1
rs(intthisfield).name = rs(intthisfield).value
Next
The only thing that doesn't work is the following line :
rs(intthisfield).name = rs(intthisfield).value
i want to create a variable that has the name of the field and then put the value in it
i want to loop through all the fields (this is why i use the * in the following query)
"SELECT * FROM cas WHERE id=814"
This returns 1 result but my table has 152 fields (i know... this is too much!) What i would like is to have some code that makes a variable for each field that i have automatically
for example, if i had a table with 3 fields (field1,field2,field3), normally i could this
field1=rs("field1")
field2=rs("field2")
field3=rs("field3")
but is it possible to automate this step?
the code would have to be like :
loop through all the fields
nameOfTheField = valueOfTheField
end loop
am i clear enough?
-------------
i just solved half of my problem with this code :
Dim rs
SQL="SELECT * FROM cas WHERE id=" & idCas
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open SQL,Conn
intfieldcount = rs.fields.count
For intthisfield = 0 To intfieldcount -1
rs(intthisfield).name = rs(intthisfield).value
Next
The only thing that doesn't work is the following line :
rs(intthisfield).name = rs(intthisfield).value
i want to create a variable that has the name of the field and then put the value in it