By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,045 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,045 IT Pros & Developers. It's quick & easy.

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

P: 4
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.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4. <%
  5. set conn=Server.CreateObject("ADODB.Connection")
  6. conn.Provider="Microsoft.ACE.OLEDB.12.0"
  7. conn.Open "c:/inetpub/wwwroot/Sparqs Database.accdb"
  8.  
  9. sql="INSERT INTO [Attendance]([S_id],[Institution_n],"
  10. sql=sql & "[Training_level],[Training_type], [Session_date], [Session_time],[F_name], [S_name], [email], [Student_id], [Course_name], [Opt_in])"
  11. sql=sql & " VALUES "
  12. sql=sql & "('"& CONVERT(Request.Form("S_id" INTEGER) & "',"
  13. sql=sql & "'" & Request.Form("Institution_n") & "',"
  14. sql=sql & "'" & Request.Form("Training_level") & "',"
  15. sql=sql & "'" & Request.Form("Training_type") & "',"
  16. sql=sql & "'" & CONVERT(Request.Form("Session_date" DATE) & "',"
  17. sql=sql & "'" & CONVERT(Request.Form("Session_time" TIME) & "',"
  18. sql=sql & "'" & Request.Form("F_name") & "',"
  19. sql=sql & "'" & Request.Form("S_name") & "',"
  20. sql=sql & "'" & Request.Form("Email") & "',"
  21. sql=sql & "'" & Request.Form("Student_id") & "',"
  22. sql=sql & "'" & Request.Form("Course_name") & "',"
  23. sql=sql & "'" & Request.Form("Opt_in") & "')"
  24.  
  25. on error resume next
  26. conn.Execute sql,recaffected
  27. if err<>0 then
  28.   Response.Write(Err.Description)
  29. else
  30.   Response.Write("<h3>" & recaffected & " record added</h3>")
  31. end if
  32. conn.close
  33. %>
  34.  
  35. </body>
  36. </html>
Apr 13 '12 #1
Share this Question
Share on Google+
6 Replies


P: 1
Int32.Convert(string)
Apr 13 '12 #2

P: 4
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(Request.Form("S_id") & "',")

/sparqs training site/Attendance.asp, line 12
Apr 13 '12 #3

Rabbit
Expert Mod 10K+
P: 12,357
Please use code tags when posting code.

You never close your convert functions.
Apr 13 '12 #4

P: 4
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.
Apr 15 '12 #5

Rabbit
Expert Mod 10K+
P: 12,357
Please show us the code after you've closed the convert functions.
Apr 16 '12 #6

P: 4
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.
Apr 17 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.