I am trying to convert string to int, date, time for access database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ANNIE4
    New Member
    • Apr 2012
    • 4

    I am trying to convert string to int, date, time for access database

    Hi everyone, I am new to this so I have been trying to convert input from form (string) to different data types but can't get it to work. Keeps telling me there is syntax error or expected ')' no matter what way I write it. Have tried everything I think. Here is my completed code. If anyone can help I would be extremely grateful and thanks in advance.

    Code:
    <html>
    <body>
    
    <%
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.ACE.OLEDB.12.0"
    conn.Open "c:/inetpub/wwwroot/Sparqs Database.accdb"
    
    sql="INSERT INTO [Attendance]([S_id],[Institution_n],"
    sql=sql & "[Training_level],[Training_type], [Session_date], [Session_time],[F_name], [S_name], [Email], [Student_id], [Course_name], [Opt_in])"
    sql=sql & " VALUES "
    sql=sql & "('"& CONVERT(Request.Form("S_id" INTEGER) & "',"
    sql=sql & "'" & Request.Form("Institution_n") & "',"
    sql=sql & "'" & Request.Form("Training_level") & "',"
    sql=sql & "'" & Request.Form("Training_type") & "',"
    sql=sql & "'" & CONVERT(Request.Form("Session_date" DATE) & "',"
    sql=sql & "'" & CONVERT(Request.Form("Session_time" TIME) & "',"
    sql=sql & "'" & Request.Form("F_name") & "',"
    sql=sql & "'" & Request.Form("S_name") & "',"
    sql=sql & "'" & Request.Form("Email") & "',"
    sql=sql & "'" & Request.Form("Student_id") & "',"
    sql=sql & "'" & Request.Form("Course_name") & "',"
    sql=sql & "'" & Request.Form("Opt_in") & "')"
    
    on error resume next
    conn.Execute sql,recaffected
    if err<>0 then
      Response.Write(Err.Description)
    else
      Response.Write("<h3>" & recaffected & " record added</h3>")
    end if
    conn.close
    %>
    
    </body>
    </html>
    Last edited by Rabbit; Apr 13 '12, 07:40 PM. Reason: Please use code tags when posting code.
  • rabindra
    New Member
    • Apr 2012
    • 1

    #2
    Int32.Convert(s tring)

    Comment

    • ANNIE4
      New Member
      • Apr 2012
      • 4

      #3
      Thanks so much for getting back to me appreciate it, but unfortunately
      error code now is:

      Microsoft VBScript runtime error '800a01a8'

      Object required: ''


      Here's the code up until now:

      sql=sql & "('"& int32.convert(R equest.Form("S_ id") & "',")

      /sparqs training site/Attendance.asp, line 12

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Please use code tags when posting code.

        You never close your convert functions.

        Comment

        • ANNIE4
          New Member
          • Apr 2012
          • 4

          #5
          Hi Rabbit,

          Just wanted to apologise for lack of code tags.

          Still having the same problem, just doesn't seem to work with any conversion that I use. I'll keep plugging away. Thanks.

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            Please show us the code after you've closed the convert functions.

            Comment

            • ANNIE4
              New Member
              • Apr 2012
              • 4

              #7
              hi Rabbit,

              Just to say first of all thanks for looking at my problem, appreciate it.

              After considerable research have finally found the correct format. Turns out that I had got it right before but that there is a problem with 64 bit OS, access 2010 and ADO/ASP conversion.

              Working with strings is fine but the minute you try to convert there is a problem. They have suggested some resolutions and patches so going to give them a go. So I guess I can close the thread.

              Thanks again.

              Comment

              Working...