Results 1 to 3 of 3

Thread: Problems

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    84

    Problems

    Why can't I use server in a VBScript function like this:

    <script language="VBScript">
    sub Inlogg()
    alias=trim(formen.alias.value)
    losen=trim(formen.losen.value)
    self.status=alias & "..." & losen

    set ConMitt = Server.CreateObject("ADODB.Connection")
    ConMitt.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath("/ps014/Community2/") & "\medlemmar.mdb"
    Set RsMitt = Server.CreateObject("ADODB.Recordset")
    SQLstr = "SELECT * FROM gaster ORDER BY Tid ASC"
    rsMitt.Open SQLstr, ConMitt

    Do Until RsMitt.EOF
    a1=RsMitt("Alias")
    a2=RsMitt("Losen")
    rsMitt.MoveNext
    Loop

    RsMitt.close
    Set RsMitt= Nothing
    ConMitt.close
    Set ConMitt = Nothing
    self.status=a1 & "..." & a2
    end sub
    </script>

    I can use in regular HTML-code if I use <% %>.

    How do I solve this problem ??



    Thanks,
    Abel

  2. #2
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    Try taking off the Server option in from these lines
    set ConMitt = Server.CreateObject("ADODB.Connection") And
    Set RsMitt = Server.CreateObject("ADODB.Recordset")

    When usinb VB script like this, you don't use 'Server'
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    You are trying to do server side work in client side script.

    Keep your recordsets on the server side.

    You also can't use server.createobject in client side code. If you did execute this code without the server. object identifyer, the user would get an error if they didn't have ADO installed.

    If you are creating objects, keep them server side and always use Server.CreateObject
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

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



Click Here to Expand Forum to Full Width