This topic is now archived and is closed to further replies.


Database programming question...

Recommended Posts

Is it possible, via ADO.Net, to obtain a given table and enumerate the names of the column in that table? My reason for wondering is that i''ve got to fill in a table entry that could have up to 78 items and it would be easier and less typo prone if I could just enumerate the names of the fields to fill and build the sql string to insert into the table iteriatively through code. so, in psuedo code:
array[] columns = table.columns;
string fields;
string values;

for( int i = 0; i < columns.count; i++ )
fields += column+",";
values += data[i]+",";

string sql = "INSERT INTO table using"+fields+"("+values+");";
no, that sql statement isn''t valid, but you get the idea i hope. Mike.

Share this post

Link to post
Share on other sites