"Tbl.Fields.Item(i).Name" gives you the name of the column.
function sqlQuerySelect(server, query, user)
{
var ConnectionString = "DRIVER=SQL Server;SERVER="+ server +";UID="+user+";PWD="+user+";
// Creates a new connection
var ConnDB = ADO.CreateConnection();
ConnDB.ConnectionString = ConnectionString;
ConnDB.Open();
var resultArray = new Array();
// Opens a recordset
var Tbl = ConnDB.Execute(query);
// Scans all records returned by the query
Tbl.MoveFirst();
var arrIndex = 0;
while (! Tbl.EOF)
{
for (i = 0; i < Tbl.Fields.Count; i++)
{
Log.Message(Tbl.Fields.Item(i).Name +" -> "+Tbl.Fields.Item(i).Value);
resultArray[arrIndex] = Tbl.Fields.Item(i).Value;
}
Tbl.MoveNext();
arrIndex++;
}
// Closes the recordset and the connection
Tbl.Close();
// Closes the recordset and the connection
ConnDB.Close();
return resultArray;
}