What is wrong here?

Results 1 to 2 of 2

Thread: What is wrong here?

  1. #1
    Join Date
    Dec 1969
    Posts
    111

    Default What is wrong here?

    When I try to write to the DB i get a Error:<BR>Microsoft OLE DB Provider for ODBC Drivers fejl &#039 80040e14&#039 <BR><BR>[Microsoft][ODBC Microsoft Access 97-driver] Syntax error in string in query expression &#039&#039)&#039. <BR><BR>Here is the code where im trying to write to the DB:<BR>Set Conn = Server.CreateObject("ADODB.Connection") <BR> conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath("postal.mdb")<BR><BR><BR> Set rs = Server.CreateObject("ADODB.Recordset") <BR><BR><BR> &#039We need to insert a record into the database <BR> SQLStmt = "INSERT INTO Postcard (" & _ <BR> "passw, postal, nameto, namefrom, " & _ <BR> "emailfrom, emailto, message, data) " & _ <BR> "VALUES (" <BR><BR> &#039 We need a random number for our password, so <BR> &#039 use randomize/rnd to make a random number. <BR> randomize() <BR> passw = Int((9999-1)*Rnd + 1) <BR><BR> SQLStmt = SQLStmt & passw & ",&#039" & session("postal") & _ <BR> "&#039,&#039" & session("nameto") & "&#039,&#039" & _ <BR> session("namefrom") & "&#039,&#039" & _ <BR> session("emailfrom") & "&#039,&#039" & _ <BR> session("emailto") & "&#039,&#039" & _ <BR> session("message") & "&#039,&#039" & session("data") & ")" <BR><BR> &#039 Write information to database <BR> rs.Open SQLStmt, Conn <BR><BR><BR>Regards<BR><BR>Christian

  2. #2
    Join Date
    Dec 1969
    Posts
    552

    Default RE: What is wrong here?

    On the last line, you need...<BR><BR>session("message") & "&#039,&#039" & session("data") & "&#039)"<BR><BR>(That appostrophe at the end, right before the close paren. All of your approstrophes need to match up. You have one right before session("data") so you need one after it!)

Posting Permissions

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