Newbie needs help--I'm close, but still no cigar

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Newbie needs help--I'm close, but still no cigar

    I'm not a script guy, and this is kicking my ass:

    I need to check the values of poll.htm against an MS Access DB and
    then build a table so the poll taker can do a final review. After poll
    taker approves the text values (the numaric values are placed in
    hidden fields) will be stored in the data base (that code is not shown
    below).

    Issue 1:
    pTitle & pAnswer should be the value from the db, pasted up from the
    function.

    I have no idea how to insert it using a document.write



    Issue 2:
    if i don't put the <% and %> down in the function I get: server
    undefined.

    if I do put them there I get:


    Error Type:
    Microsoft VBScript compilation (0x800A0401)
    Expected end of statement
    /PollingTry2/SurveyWork1.asp, line 144, column 96
    var strCnxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source='C:\Inetpub\wwwroot\fpdb\poll.mdb';";
    -----------------------------------------------------------------------------------------------^


    I got the sample db code from MSDN and it should be javascript, but
    the error message says VBScript.

    So, I need to get set the variables down in function "ListValue". Or
    should I use some kind of return method. How do I return 2 variables?



    This is the code from my asp page. there's nothing in the header to
    speak of.

    <body>
    <SCRIPT LANGUAGE="JavaScript" RUNAT="server">

    <!--

    var i, pos, argname, value, queryString, pairs,pAnswer, Q,pVal,
    pTitle,CellBG,FontColor;

    queryString = location.search.substring(1);

    pairs = queryString.split("&");


    //start the table


    document.writeln('<table border="1" cellpadding="4" cellspacing="0"
    style="border-collapse: collapse" bordercolor="#FBAE4A" width="67%"
    id="AutoNumber2" height="313">');

    //run through the values of the poll page


    for (i = 0; i < pairs.length; i++)
    {
    pos = pairs[i].indexOf('=');
    if (pos == -1)
    {
    continue;
    }
    argname = pairs[i].substring(0,pos);
    value = pairs[i].substring(pos+1);

    // argname is the name of the radio button
    //value is the value of the radio button


    switch (argname){
    case 'QID1' : // Title: Question 1?


    //go to the listvalue function and check the values against the db

    ListValue(argname, value);



    if (pAnswer ="None Selected") {
    CellBG = '#000000';
    FontColor = '#FF66FF';
    } else {
    CellBG = '#193789';
    FontColor = '#00FF00';
    }



    document.writeln('<tr>');

    //pTitle should be the value from the db *********


    document.writeln('<td width= "83%" height= "40" bgcolor=
    "CellBG">pTitle</td>');
    document.writeln('<td width= "17%" height= "40" align= "center">');
    document.writeln('<p align= "center"><b><font color= "FontColor">');

    //pAnswer should be the value from the db ***********

    document.writeln(pAnswer)

    document.writeln('</font></b></td>');
    document.writeln('<input type="hidden"name="QID" value= & pAnswer &
    >');
    document.writeln('</tr>');
    break;

    }

    document.writeln("</table>");


    function ListValue(Q,pVal)
    {
    // record variables
    // var fld, filter
    //var showBlank = " "
    //dim showNull = "-NULL-"
    Dim SQLPollValues

    // connection and recordset variables
    set Cnxn = Server.CreateObject("ADODB.Connection")
    strCnxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    Source='C:\Inetpub\wwwroot\fpdb\poll.mdb';"
    set rsPollValues = Server.CreateObject("ADODB.Recordset")
    SQLPollValues = "SELECT * FROM Qry_Answers WHERE QID=" & Q & " AND
    answer_id='" & pVal & "'"




    //open connection
    Cnxn.Open(strCnxn)

    // create recordset client-side using object refs
    rsPollValues.ActiveConnection = Cnxn
    rsPollValues.CursorLocation = adUseClient
    rsPollValues.CursorType = adOpenKeyset
    rsPollValues.LockType = adLockOptimistic
    rsPollValues.Source = SQLPollValues
    rsPollValues.Open()

    rsPollValues.MoveFirst()

    if (rsPollValues.RecordCount = 0) then
    Response.Write("No records matched ")
    Response.Write (SQLPollValues + "So cannot make table...")
    Cnxn.Close()
    Response.End

    else
    if (Q = 9) then
    pAnswer = rs.field("answer")
    pTitle = rs.field("title")
    else
    pAnswer = rs.field("StateFullName")
    pTitle = rs.field("title")

    end if
    end if



    // Response.Write(e.message)



    // finally

    // clean up
    if (rsPollValues.State = adStateOpen) then
    rsPollValues.Close
    end if

    if (Cnxn.State = adStateOpen) then
    Cnxn.Close
    rsPollValues = null
    Cnxn = null
    end if




    }
    //-->
    </script>
    </body>
    Borg Vomit Guest

  2. Similar Questions and Discussions

    1. So close, yet so far...
      Hi all, I'd appreciate any pointers to get my setup running correctly. I have Flash Media Server 2.0 (Developer edition) on my local machine. I...
    2. SO CLOSE!
      I'm using coldfusion and the MYSQL Migration toolkit to create my web application but when I'm trying to convert my access database to mysql...
    3. close my project that is in a browser window (close this window)
      How can I do this with a button? What do I have to put into button?
    4. Wanna buy a Cigar?....
      Is this legal???? Or is our legs being pulled. "Infidel Castro" <gimme_info@sympatico.ca> wrote in message...
    5. up close
      Hi, How close are you getting? Sometimes you have to get into Macro mode ( if you camera has it). Also check your manual. If you get closer than...
  3. #2

    Default Re: Newbie needs help--I'm close, but still no cigar

    Delete that superfluous ; at the end of your connection string.

    Ray at work

    "Borg Vomit" <not_phrynicous@hotmail.com> wrote in message
    news:ca4cf807.0309180940.73ab3de4@posting.google.c om...
    >
    > Error Type:
    > Microsoft VBScript compilation (0x800A0401)
    > Expected end of statement
    > /PollingTry2/SurveyWork1.asp, line 144, column 96
    > var strCnxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    > Source='C:\Inetpub\wwwroot\fpdb\poll.mdb';";
    > --------------------------------------------------------------------------
    ---------------------^
    >

    Ray at Guest

  4. #3

    Default Re: Newbie needs help--I'm close, but still no cigar

    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message news:<e429dAhfDHA.2400@TK2MSFTNGP11.phx.gbl>...
    > Delete that superfluous ; at the end of your connection string.
    >
    > Ray at work

    Thanks Ray, but I still get:

    Microsoft JScript runtime error: 'Server' is undefined




    I admit I don't understand why some lines need ; and some don't. Is
    there a difference between Jscript and javascript? I think I'm using
    2 different scripts... i have no idea.

    I think I'm going to try to use "queryString.split" etc in VBscript,
    if I can't get what I have to work. At least it'll all be MS...
    suggestions?
    Borg Vomit Guest

  5. #4

    Default Re: Newbie needs help--I'm close, but still no cigar

    You are using JScript syntax in a VBScript page (note the error message says
    "VBScript compilation").
    Add <%@ LANGUAGE = JScript %> at the top of the page.

    --
    Mark Schupp
    --
    Head of Development
    Integrity eLearning
    Online Learning Solutions Provider
    [email]mschupp@ielearning.com[/email]
    [url]http://www.ielearning.com[/url]
    714.637.9480 x17


    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:e429dAhfDHA.2400@TK2MSFTNGP11.phx.gbl...
    > Delete that superfluous ; at the end of your connection string.
    >
    > Ray at work
    >
    > "Borg Vomit" <not_phrynicous@hotmail.com> wrote in message
    > news:ca4cf807.0309180940.73ab3de4@posting.google.c om...
    >
    > >
    > > Error Type:
    > > Microsoft VBScript compilation (0x800A0401)
    > > Expected end of statement
    > > /PollingTry2/SurveyWork1.asp, line 144, column 96
    > > var strCnxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
    > > Source='C:\Inetpub\wwwroot\fpdb\poll.mdb';";
    >
    > --------------------------------------------------------------------------
    > ---------------------^
    > >
    >
    >

    Mark Schupp Guest

  6. #5

    Default RE: Newbie needs help--I'm close, but still no cigar

    Hi Borg,

    I found you use both VBScrip and JavaScript in one page, the syntax of them
    are not compatible. I suggest you may first clean up your code, adn only
    use one language, for example, VBScript if you want the functions in it. Or
    you can put them in different script block, for example:

    <script language=VBScript runat=server>

    Response.Write server.MapPath("\")

    </script>


    <script language=JScript runat=server>

    Response.Write(Server.MapPath("\\"));

    </script>


    Luke
    Microsoft Online Partner Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    MSFT Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139