Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call a Recordset in CFScript

Status
Not open for further replies.

danielhai

Programmer
Oct 23, 2001
25
0
0
US
How do I call a recordset field with the JS in CFScript? I tried oRs.Fields["RowName"].value but it didn't work? Any help? My code is below ...

<CFOBJECT TYPE=&quot;COM&quot;
ACTION=&quot;CREATE&quot;
CLASS=&quot;ADODB.Connection&quot;
NAME=&quot;oConn&quot;>

<CFOBJECT TYPE=&quot;COM&quot;
ACTION=&quot;CREATE&quot;
CLASS=&quot;ADODB.Recordset&quot;
NAME=&quot;oRs&quot;>

<cfscript>
DSNTxt = &quot;DRIVER={Microsoft Text Driver (*.txt; *.csv)};HDR=Yes;Persist Security Info=False;DBQ=&quot; & #ExpandPath(&quot;./upload/&quot;)#;
WriteOutput(&quot;DSNTxt: &quot; & DSNTxt & &quot;<br>&quot;);

strSQL = &quot;select * from &quot; & URL.FileName;
WriteOutput(&quot;SQL: &quot; & strSQL & &quot;<br><br>&quot;);

oConn.Open (&quot;#DSNTxt#&quot;,&quot;&quot;,&quot;&quot;,-1);
oRs.Open (strSQL, oConn, 1,1,1);

while (not oRs.EOF) {
WriteOutPut(oRs.Fields[&quot;FieldName&quot;].value);
oRs.MoveNext();
}

oRs.Close();
oConn.Close();
 
Im unfamiliar with your COM object, which is why its hard to pin down what your problem is. What line was the error on?

My first suggestion is to look back at the example you have for how to access records for your ORS object.

oRs.Fields[&quot;FieldName&quot;].value

I believe FieldName was meant for you to put the name of a field. I do not know about .value , that sounds like javascript. Are these fields from a table or from a form on another page? Id suggest testing the output without the while loop until you get the syntax right.

good luck
 
i tried that, I'm just trying to use the simple Microsoft ADO Recordset Object, but I have a problem when I try to refer to the value on one line.

Instead of oRs.Fields(&quot;FieldName&quot;).value, I have to set:

MyFields = oRs.Fields
MyFieldName = MyFields(&quot;FieldName&quot;)
MyFieldValue = MyFieldName.value

where FieldName is the row I'm trying to access. Is there a way to do this in CFScript?
 
I think I posted a thanks to icqof188 for his original post which works very well :)

thread232-49003
 
i already looked at that. there's got to be a faster and easier way then creating a query, then populating it. I'd just rather WriteOutPut(recordset(column)), then go through the slow process of creating the query. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top