Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Recordset syntax

New Here ,
Mar 01, 2007 Mar 01, 2007
Hi there. I'm having some problems with the proper syntax for retrieving a recordset.

the normal call dreamweaver generates: <%= (rsOrder.Fields.Item("UserEmail").Value) %>

however I'm looping through an array where the field is represented by a variable. My question is what would the proper syntax be to accomplish this?

thanx ahead of time
TOPICS
Server side applications
853
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Mar 01, 2007 Mar 01, 2007
I believe the error is happening with the use of the replace function in your select statement. For example Replace(rsOrder__filterField, "'", "''"); this would be the results

before replace: "ID"
after replace: ""ID""

I think you may be adding too many quotations, you don't need quotations around your column names in your select statement. Also, your filter fields needs to equal something. It doesn't look like your filter fields are being compared to anything. Therefore you have too few param...
Translate
Contributor ,
Mar 01, 2007 Mar 01, 2007
Could you please clarify what you are trying to do? I am not quite understanding. And could you post your loop code?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 01, 2007 Mar 01, 2007
thanx for the quick reply. this is what I'd like to do:

<% For i=0 to uBound(arrHeadings) %>
<td align="center"><%= (rsOrder.Fields.Item(cstr(arrHeadings(i))).Value) %></td>
<% Next %>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 01, 2007 Mar 01, 2007
I am assuming you dim arrHeadings as an array. Well arrHeadings is just an array variable it is not contained in the recordset, so the syntax you are using won't work. Have you populated the arrHeadings array yet? if not what are you trying to populate it with?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 01, 2007 Mar 01, 2007
arrHeadings comes from:

If (Request.Form("SelectFields") <> "") Then
rsOrder__selectField = cstr(Request.Form("SelectFields"))
arrHeadings = split(rsOrder__selectField,",")
End If

the array is definitely populated as I can write it out on its own. thats why I'm thinking that my syntax is off.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 01, 2007 Mar 01, 2007
That looks fine. Just make sure that the strings in arrHeadings match the
column names returned by your recordset.

"NetComp" <webforumsuser@macromedia.com> wrote in message
news:es74f1$pdo$1@forums.macromedia.com...
> thanx for the quick reply. this is what I'd like to do:
>
> <% For i=0 to uBound(arrHeadings) %>
> <td align="center"><%= (rsOrder.Fields.Item(cstr(arrHeadings(i))).Value)
> %></td>
> <% Next %>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 01, 2007 Mar 01, 2007
I'm getting this error with that code: Requested operation requires a current record

The field names all match up but for some reason its not picking it up??
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 02, 2007 Mar 02, 2007
"NetComp" <webforumsuser@macromedia.com> wrote in message
news:es8fkr$en7$1@forums.macromedia.com...
> I'm getting this error with that code: Requested operation requires a
> current record

That means you don't have any results in your recordset. If you try to
access a recordset field when there are no records, you'll get an error
saying that the requested operation requires a current record.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 01, 2007 Mar 01, 2007
sorry, had to run to the store. Try this then:

<% For i=0 to uBound(arrHeadings) %>
<td align="center"><%= arrHeadings(i)%></td>
<% Next %>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 01, 2007 Mar 01, 2007
that I can do...but I'm trying to substitute the variable for the actual field value it represents.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 01, 2007 Mar 01, 2007
Oh I think I understand now. Try placing the array in quotes rs.fields.item("arrHeadings(i)").value
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 01, 2007 Mar 01, 2007
Does the recordset return a result when you test it, or is it filtered by something?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 01, 2007 Mar 01, 2007
sorry I guess I'm leaving out some parts of the picture, heres the source.

http://www.lumberlinkonline.com/temp/test.txt

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 01, 2007 Mar 01, 2007
Okay, I am close to solving your first problem with the array. I should have that solution for you in a few minutes. The second problem with the recordset just means that what ever criteria you are filtering by is not returning any results thefore the recordset is empty.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 01, 2007 Mar 01, 2007
Yeah I think its the filterFields that I'm having the problem with.

Request.Form("FilterFields") looks something like this UserID=1,UserFirstName=Rob

I then use Replace(Request.Form("FilterFields"),","," AND ") to get it into UserID=1 AND UserFirstName=Rob for the WHERE statement.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 01, 2007 Mar 01, 2007
Okay, after testing multiple solutions this one worked for me, and I believe it is very similar to what you have.

<% for x = 0 to ubound(myArray)%>
<td><%=rsTest.fields.item(myArray(x)).value%></td>
<%next%>

I really don't know why yours wasn't working, unless the values in your array weren't matching with what was in the DB.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 01, 2007 Mar 01, 2007
he, he yeah I tried that. I think the problem is occuring in the select statement...if you have a look at the source again of the select statement, is there anything in there that looks wrong in terms of how I'm getting the WHERE params?

the error message I'm getting now is "Too few parameters"

thanx for hanging in there with me!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 01, 2007 Mar 01, 2007
I believe the error is happening with the use of the replace function in your select statement. For example Replace(rsOrder__filterField, "'", "''"); this would be the results

before replace: "ID"
after replace: ""ID""

I think you may be adding too many quotations, you don't need quotations around your column names in your select statement. Also, your filter fields needs to equal something. It doesn't look like your filter fields are being compared to anything. Therefore you have too few parameters.

Make sure you only use the replace function when you actaully need to replace something.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 02, 2007 Mar 02, 2007
thats did it! Thanx again for hanging in there.....I appreciate it.

what part of the world are you in? I thought I was the only person that worked at 3:00 am!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 02, 2007 Mar 02, 2007
I am in Boise, Idaho. How about you?

Anyways, I never go to sleep before 1:00 am. I am a night owl.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 02, 2007 Mar 02, 2007
LATEST
I'm in a small town in SW Ontario, 20 min from Lake Erie


hope your weather is better than ours right now!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines