Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    expected end of statement.

    i have this code: what its meant to do is recieve the variable entered into the date field on a form and then post to this script and then lookup the id number corresponding to this date and insert that id number into another table.

    When you run this script we get error:

    Error Type:
    Microsoft VBScript compilation (0x800A0401)
    Expected end of statement
    /testing/add.asp, line 27, column 23


    Code:
    <%@ Language="VBScript" %>
    <% Option Explicit %> 
    <html>
    <head>
    <title>Form to database</title>
    </head>
    <body> 
    <%
    DIM objConn
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
    Server.MapPath ("bookings.mdb") & ";"
    objConn.Open
    
    DIM mySQL
    date1 = Request.Form("date1")
    mySQL = "SELECT cal.id where cal.date = " & date1 & " ;"
    
    DIM objRS
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.Open mySQL, objConn
    
    'declare your variables
    Dim date1, roombooked1, from1, to1, name1, eventname1, address1, phone1, price1, equipment1, layout1, caretaking1, insurance1, riskass1, other1, start1, end1, invnum1
    Dim sConnString, connection, sSQL
    'Receiving values from Form, assign the values entered to variables
    date1 = Response.Write objRS("cal.id")
    roombooked1 =Request.Form("roombooked")
    from1 =Request.Form("from")
    to1 =Request.Form("to")
    name1 =Request.Form("name")
    eventname1 =Request.Form("eventname")
    address1 =Request.Form("address")
    phone1 =Request.Form("phone")
    price1 =Request.Form("price")
    equipment1 =Request.Form("equipment")
    layout1 =Request.Form("layout")
    caretaking1 =Request.Form("caretaking")
    insurance1 =Request.Form("insurance")
    riskass1 =Request.Form("riskass")
    other1 =Request.Form("other")
    start1 =Request.Form("start1")
    end1 =Request.Form("end1")
    invnum1 =Request.Form("invnum1")
    
    'declare SQL statement that will query the database 
    sSQL = "INSERT into bookings (date1, roombooked1, name1, eventname1, address1, phone1, price1, equipment1, layout1, caretaking1, insurance1, riskass1, other1, start1, end1, invnum1) values ('" & _
    date1 & "', '" & roombooked1 & "', '" & name1 & "', '" & eventname1 & "', '" & address1 & "', '" & phone1 & "', '" & price1 & "', '" & equipment1 & "', '" & layout1 & "', '" & caretaking1 & "', '" & insurance1 & "', '" & riskass1 & "', '" & other1 & "', '" & start1 & "', '" & end1 & "',  '" & invnum1 & "')" 
    'define the connection string, specify database
    'driver and the location of database
    sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ 
    "Data Source=" & Server.MapPath("bookings.mdb") 
    'create an ADO connection object 
    Set connection = Server.CreateObject("ADODB.Connection")
    
    'Open the connection to the database
    connection.Open(sConnString)
    
    'execute the SQL 
    connection.execute(sSQL)
    
    response.redirect "main.asp"
    'Done. Close the connection object
    connection.Close
    Set connection = Nothing
    %>
    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    date1 = Response.Write objRS("cal.id")

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that means nothing.... is that wrong?

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Look at your code and you'll find out.

  • #5
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well i dont see anythin wrong unless you cant use a response.write in that location. if not how else can i do it?

  • #6
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    date1 = Response.Write objRS("cal.id")
    roombooked1 =Request.Form("roombooked")
    It is invalid syntax to assign a variable and response.write at the same time.

    I'm not sure what you are trying to do
    date1 = objRS("cal.id") ???
    date1 = Request.Form("...") ???


  •  

    Posting Permissions

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