954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Variable named as mssql column name

Hello,

I would like to create a small procedure that fetches the names of the columns of a table and uses them as a variable name.

Let me explain.

TableA
Ref, FullName, FirstName, Age, ...
1, Jones, Charles, 32
2, Bridge, Dom, 26
3, Goodtime, Jack, 46
...

And I would use in my asp procedure variables with the names of the columns without having to copy many of the names of the columns.

FullName =
FirstName =
Age =
...

Below the concept but of course it can not function as it is.

Set RS = Server.CreateObject ("ADODB.Recordset")
Rs.Open "SELECT * FROM TableA WHERE Ref = '" & Session ("Ref ")&"'", adoCon, 3, 3
For Each f in rs.Fields
f.Name = RS (f.Name)
next
Rs.Close: set RS = nothing
Response.write "The name is "&FullName

Result:
If Session ("Ref") = 1 we should have
The name is Jones

This would assign all the variables even if the evolutionary table.

I hope to be clear enough;-)

Thank you for your help

Eric

ErGa
Newbie Poster
1 post since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: