SnippetCollection
Forums  
Links
 
Support
 


snippetCollection.com Forum Index FAQ Memberlist Search Usergroups Profile Log in to check your private messages Log in Register
Welcome to SnippetCollection.com, a friendly and fast growing community of programmers, coders, web application developers and more. You are currently viewing our forums as a guest!

This message will go away once you are registered. Also, by registering you will have access to all post topics, communicate privately with other members (PM), respond to polls and access other special features. Registration is fast, simple and absoultely free so please Click Here to join our community

Enjoy our great collection of snippets and tutorials!

Log in
Username:
Password:

 

Our Sponsors
           
Want to list your business here. Contact us.
 Functions & arrays View next topic
View previous topic
Post new topic Reply to topic
Author Message
Harro



Joined: 29 Aug 2005
Posts: 31
Location: Belgium

PostPosted: Sat Apr 15, 2006 7:32 pm Reply with quoteBack to top

Have a little difficulty using an array as a return value.
Situation:

Got a function that collects the data of a certain record in a database.
All the values of the fields are stored in an array.
This function is on a page functions.asp and is included on certain pages.
On nother page I need the data of this array.
But for some reason I'm not able to get that array on that page.

Here's the function:
Code:
private function getPlanDetails(planid)
   dim aTemp()
   dim intTeller

   cnn.open
   dim rstPlannen
   set rstPlannen = server.CreateObject("adodb.recordset")
   rstPlannen.activeconnection = cnn
   rstPlan.open("SELECT p.planID, p.planNaam, p.situering, p.prioriteit, d.omschrijving, o.omschrijving as opleiding, v.voornaam, v.naam, p.academiejaar, p.[plan], p.do, p.[check], p.act FROM tblPlan p, tblVerantwoordelijke v, tblDomein d, tblOpleiding o WHERE (p.domeinID = d.domeinID OR p.domeinID IS NULL) AND (p.verantwoordelijkeID = v.verantwoordelijkeID OR p.verantwoordelijkeID IS NULL) AND (o.opleidingID = p.opleidingID OR p.opleidingID IS NULL) AND p.planID=" & planID)
   
   ReDim aTemp(rstPlannen.fields.count)
   
   for intTeller = 0 to rstPlannen.fields.count -1
      if rstPlannen.fields(intTeller) = "" then
         aTemp(intTeller) = "-"
      else
         aTemp(intTeller) = rstPlannen.fields(intTeller)
      end if
   next
   
   getPlanDetails = aTemp
   
   rstPlannen.close
   set rstPlannen = nothing
   cnn.close
end function


On the other page (functions.asp is included) I have this:
Code:
   dim aPlannen()
   aPlannen = getPlanDetails(intPlanID)


but whenever I want to get a value from the array, it returns nothing...
Any suggestions?


[edit]
Seems like it's an error in my sql querry
Code:
SELECT p.planID, p.planNaam, p.situering, p.prioriteit, d.omschrijving, o.omschrijving as opleiding, v.voornaam, v.naam, p.academiejaar, p.[plan], p.do, p.[check], p.act
FROM tblPlan p, tblVerantwoordelijke v, tblDomein d, tblOpleiding o
WHERE (p.domeinID = d.domeinID OR p.domeinID IS NULL)
AND (p.verantwoordelijkeID = v.verantwoordelijkeID OR p.verantwoordelijkeID IS NULL)
AND (o.opleidingID = p.opleidingID OR p.opleidingID IS NULL) AND p.planID=" & planID)
crashed



Joined: 12 Sep 2005
Posts: 156
Location: England

PostPosted: Mon Apr 17, 2006 3:06 pm Reply with quoteBack to top

Obvious errors from a quick glance at your SQL

Code:
SELECT p.planID, p.planNaam, p.situering, p.prioriteit, d.omschrijving, o.omschrijving as opleiding, v.voornaam, v.naam, p.academiejaar, p.[plan], p.do, p.[check], p.act
FROM tblPlan p, tblVerantwoordelijke v, tblDomein d, tblOpleiding o
WHERE (p.domeinID = d.domeinID OR p.domeinID IS NULL)
AND (p.verantwoordelijkeID = v.verantwoordelijkeID OR p.verantwoordelijkeID IS NULL)
AND (o.opleidingID = p.opleidingID OR p.opleidingID IS NULL) AND p.planID=" & planID & ")"

^You left off the last "

Otherwise,

If it is an error in your sql, the best place to debug that would be Microsoft SQL Management Studio Express (free from MS website).

Just run your query in there and it should give you the error if there is one.

Rgds,
Chris
Harro



Joined: 29 Aug 2005
Posts: 31
Location: Belgium

PostPosted: Wed Apr 19, 2006 10:53 pm Reply with quoteBack to top

Found the error.
Was something completly different.
The last planID came from a request.form.
But made a little typo there.
So planID had a NULL value, and that created the error.
Hereis however a better way to write that query:

Quote:
SELECT p.planID
, p.planNaam
, p.situering
, p.prioriteit
, d.omschrijving
, o.omschrijving as opleiding
, v.voornaam
, v.naam
, p.academiejaar
, p.[plan]
, p.do
, p.[check]
, p.act
FROM tblPlan p
left outer
join
tblVerantwoordelijke v
on v.verantwoordelijkeID = p.verantwoordelijkeID
left outer
join
tblDomein d
on d.domeinID = p.domeinID
left outer
join
tblOpleiding o
on o.opleidingID = p.opleidingID
WHERE p.planID = planID
Display posts from previous:      
Post new topic Reply to topic


 Jump to:   



View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme
All times are GMT