Function returning object reference

Results 1 to 3 of 3

Thread: Function returning object reference

  1. #1
    Join Date
    Dec 1969

    Default Function returning object reference

    what i am trying to do is encapsulate all the initiatlization stuff i do everytime i make a database query. really the only difference between one query and another is the variable to which the query object is assigned and the actual select statement so i figured why not put that into a function that takes in the query string and returns the pointer so i wrote this:<BR><BR>Function startDBQuery(query)<BR> set dbQuery = Nothing<BR> set dbQuery = Server.CreateObject("ADODB.Recordset")<BR> dbQuery.ActiveConnection = MM_Conference_STRING<BR> dbQuery.Source = query<BR> dbQuery.CursorType = 0<BR> dbQuery.CursorLocation = 2<BR> dbQuery.LockType = 3<BR> dbQuery.Open()<BR> dbQuery_numRows = 0<BR> startDBQuery=dbQuery<BR>end function<BR><BR>and called it by doiung something like this:<BR><BR>set AttendeeMX = startDBQuery("SELECT max(AttendeeID) as MaxID FROM Attendees")<BR><BR>the problem is that something is messed up in the return and pointer definition because the variable pointer in this case AttendeeMX cannot have any methods called on it without giving me an error leading me to conclude that there is something wrong with this pointer reference. the problem i do not know what the error is<BR><BR>any help would be great <BR>thanks<BR>andrew

  2. #2
    Join Date
    Dec 1969

    Default RE: Function returning object reference

    set startDBQuery=dbQuery<BR>

  3. #3
    Join Date
    Dec 1969

    Default Doesn't work that way

    You don&#039;t get the actual pointer like in C.<BR><BR>What you get when you do &#039;set&#039;, is you get the QueryInterface ID that references the object. Ya can&#039;t manipulate the pointer since VBS has no capabilites to do so.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts