Question

  • Creator
    Topic
  • #2150621

    ASP Survey Problems (SQL Database)

    Locked

    by rouschkateer ·

    I am trying to retrieve database results from an html form page and dump the results into an SQL table. The only problem is that the radio buttons are varchar and the table is looking for intergers so I can calculate the results easier. My boss wants me to use his code to change the varchars into ints. Hopefully, this isn’t too long of a code for my fine members to hack out.

    I think what is going on is that the programming languages are mixed and the pahge simply doesn;t know what to do.

    The error I receive is:
    Microsoft VBScript compilation (0x800A0401)
    Expected end of statement
    /Survey/submit.asp, line 39, column 28

    Here is the code:
    <%@ Language="VBScript" %>

    <% Option Explicit %>


    Pennsylvania School of Business Student Survey – ASP Page


    <% 'declare your variables dim connection,recordset Dim WorkArea, Equipment, Environment, Instructor, ClassName, ClassTime, Term, InstrGreet, InstrKnow, SubMatter, SubPres, AskQ, Discip Dim IndHelp, InstrComment, Tutoring, TutorQ, ProgPres, OverAll, GenComment 'Receiving values from Form, assign the values entered to variables WorkArea = Request.Form("WorkArea") Equipment= Request.Form("Equipment") Environment=Request.Form("Environment") INSTRUCTOR= Request.Form("INSTRUCTOR") ClassName= Request.Form("ClassName") ClassTime= Request.Form("ClassTime") Term= Request.Form("Term") InstrGreet= Request.Form("InstrGreet") InstrKnow= Request.Form("InstrKnow") SubMatter= Request.Form("SubMatter") SubPres= Request.Form("SubPres") AskQ= Request.Form("AskQ") Discip = Request.Form("Discipline ") IndHelp= Request.Form("IndHelp") InstrComment= Request.Form("InstrComment") Tutoring= Request.Form("Tutoring") TutorQ= Request.Form("TutorQ") ProgPres= Request.Form("ProgPres") Overall= Request.Form("Overall") GenComment= Request.Form("GenComment") %>

    <% dim SQL, sConnString 'declare SQL statement that will query the database SQL = "INSERT into surveys (WorkArea, Equipment, Environment, INSTRUCTOR, ClassName, ClassTime, Term, InstrGreet, InstrKnow, SubMatter, SubPres, AskQ, Discip , IndHelp, InstrComment, Tutoring, TutorQ, ProgPres, Overall, GenComment) values ('" & _ WorkArea & "', '" &Equipment& "', '" & Environment& "', '" & _ INSTRUCTOR& "', '" & ClassName& "', '" & ClassTime& "', '" & Term& "', '" & InstrGreet& "', '" & _ InstrKnow& "', '" & SubMatter& "', '" & SubPres& "', '" & _ AskQ& "', '" & Discip & "', '" & IndHelp& "', '" & _ InstrComment& "', '" & Tutoring& "', '" & TutorQ& "', '" & _ ProgPres& "', '" & Overall& "', '" & GenComment& "')" 'define the connection string, specify database 'driver and the location of database sConnString="DSN=ConSql;Server=psbhelp;Database=survey;UID=sa;Password=password;" 'create an ADO connection and recordset Set connection = Server.CreateObject("ADODB.Connection") Set recordset = Server.CreateObject("ADODB.Recordset") 'Open the recordset object, execute the SQL statement recordset.Open SQL,connection connection.Open(sConnString) connection.Execute(SQL) If recordset.eof then response.write "There were no records returned." Else response.write "There are records returned." End if 'close the connection and recordset objects freeing up resources Recordset.Close Set Recordset=nothing Connection.Close Set Connection=nothing 'broken code follows below 'declare SQL statement that will query the database 'SQL="SELECT * FROM surveys" 'sConnString="DRIVER={SQL Server};SERVER=192.168.1.254,1433;UID=sa;PWD=password;DATABASE=survey;" 'sConnString="DSN=ConSql;Server=192.168.1.254,1433;Database=survey;Network Library=DBMSSOCN;UID=sa;Password=password;" %>

All Answers

  • Author
    Replies
    • #2914153

      Clarifications

      by rouschkateer ·

      In reply to ASP Survey Problems (SQL Database)

      Clarifications

    • #2914113

      Lets look at one thing at a time shall we..

      by shellbot ·

      In reply to ASP Survey Problems (SQL Database)

      Sorry..what is it that you are trying to do? Trying to fix the following error, or trying to get a varchar into an integer?
      This error would indicate your code is missing something..

      “The error I receive is:
      Microsoft VBScript compilation (0x800A0401)
      Expected end of statement
      /Survey/submit.asp, line 39, column 28”

      If this is the first thing you are trying to solve, post lines 37-42 from submit.asp and point out which line is which.

      gotta ask mate, is this an internal site or a website? Its just the DBA in me..I shiver to see ‘sa’ used for anything..and to see it with a password of ‘password’ is a life sentence….

    • #2915105

      Thanks dude

      by shellbot ·

      In reply to ASP Survey Problems (SQL Database)

      was great of you to come back here and check up on this. only spent 15 mins looking your code and stuff..and then ask you to provide some more info so i could help you..

      no worries, had nothing else to do anyways..

      this is why i don’t bother with the questions area anymore…no one posts back..or if ya do help..don’t get a thumbs for it anyways..

      • #2873546

        I’m Sorry

        by rouschkateer ·

        In reply to Thanks dude

        I was supposed to get e-mail replied of anyone posted, but I never did, so, yeah, I ASSumed no one replied. My apologies, and I fixed it.

Viewing 2 reply threads