Skip to main content
Known Participant
April 30, 2014
Answered

DataTable in Coldfusion (in cfscript)

  • April 30, 2014
  • 1 reply
  • 1603 views

Hi i want to add DataTable in Coldfusion script...Like c# code...C# code is following:

                    

                   DataTable productPropertyFilterTable = new DataTable();

                    productPropertyFilterTable.Columns.Add("RowID", typeof(int));

                    productPropertyFilterTable.Columns.Add("PropertyId", typeof(long));

                    productPropertyFilterTable.Columns.Add("PropertyWeight", typeof(string));

                    productPropertyFilterTable.Columns.Add("LowerRange", typeof(float));

                    productPropertyFilterTable.Columns.Add("UpperRange", typeof(float));

This topic has been closed for replies.
Correct answer duncancumming

You want to use QueryNew and QueryAddColumn.

productPropertyFilterTable  = queryNew('');

queryAddColumn(productPropertyFilterTable, 'RowID', 'Integer');

queryAddColumn(productPropertyFilterTable, 'PropertyWeight', 'VarChar');

Alternatively you can just do the same with QueryNew on its own.

productPropertyFilterTable  = queryNew('RowID,PropertyWeight', 'Integer,VarChar');

1 reply

duncancummingCorrect answer
Participating Frequently
April 30, 2014

You want to use QueryNew and QueryAddColumn.

productPropertyFilterTable  = queryNew('');

queryAddColumn(productPropertyFilterTable, 'RowID', 'Integer');

queryAddColumn(productPropertyFilterTable, 'PropertyWeight', 'VarChar');

Alternatively you can just do the same with QueryNew on its own.

productPropertyFilterTable  = queryNew('RowID,PropertyWeight', 'Integer,VarChar');

Known Participant
May 1, 2014

How to add data in datatabel like C# Code:

productPropertyFilterTable.Rows.Add(i, wordsStrings[0], wordsStrings[3], Limit[0], Limit[1]);

Participating Frequently
May 1, 2014

Now you need to use QueryAddRow and QuerySetCell