Results 1 to 8 of 8

Thread: writing textarea to database

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    writing textarea to database

    My ASP page (using VBScript), doens't seem to like my request of writing the contents from a textarea to a field in my database. The field is set to data type Memo. I get the following error when the page loads:

    Code:
    Microsoft OLE DB Provider for ODBC Drivers error '80004005' 
    
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. 
    
    /forums/postnew.asp, line 37
    Where, line 37 tells the page to update the recordset (Message_Data.Update)

    Here is the page I am talking about:
    http://www.pcgamesforyou.com/forums/postnew.asp

    Thank you.
    Alexander
    Last edited by spandex44; Jul 14th, 2001 at 11:27 AM.

  2. #2
    Lively Member
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    115
    It would be easier if you gave us some code we could look at...

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334
    Here's the entire code for that page:
    Code:
    <html>
    <head>
    <title>Post New</title>
    </head>
    <body>
    
    <form method="POST" action="postnew.asp">
    <b>Username: </b>
    <input type="text" width="50" name="txtUsername">
    <br>
    <b>Title: </b>
    <input type="text" width="50" name="txtTitle">
    <br>
    <b>Message: </b>
    <br>
    <textarea name="txtText" rows="6" cols="50"></textarea>
    <br>
    <input type="submit" value="Sign Up">
    </form>
    
    <%
    Const adOpenStatic = 3
    Const adLockOptimistic = 3
    Dim Connect, User_Data, Query
    Set Connect = Server.CreateObject("ADODB.Connection")
    Connect.Open "forum_database"
    Set User_Data = Server.CreateObject("ADODB.Recordset")
    Query = "SELECT * FROM messages"
    User_Data.Open Query, Connect, adOpenDynamic, adLockOptimistic
    User_Data.AddNew
    User_Data("Poster") = Request("txtUsername")
    User_Data("Title") = Request("txtTitle")
    User_Data("Text") = Request("txtText")
    User_Data.Update
    %>
    
    </body>
    </html>
    Here, forum_database is my DSN, connect is my ADODB connection, and messages is a table in my database with the fields: Username, Title, and Text

  4. #4
    Lively Member
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    115
    Try this instead...

    Code:
    Set Connect = Server.CreateObject("ADODB.Connection")
    Connect.Open "forum_database"
    Connect.Execute("INSERT INTO messages (Poster,Title,Text) VALUES ('" & Request("txtUsername") & "','" & Request("txtTitle") & "','" & Request("txtText") & "')")

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334
    Nah, that didn't wnat to work either, unfortunately. That is just a different way of posting that information to the database, I think that the problem lies with the data type of the database's field, or the type of input object (textarea), because I am able to write normal textboxes to a database.

  6. #6
    Lively Member
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    115
    When I save textarea-values into a database I use PM as type in the dbase. I think this is the Swedish version, and I'm pretty sure that PM is the same thing as Memo...
    try
    Code:
    response.write(request("txtText"))
    and see if it has a value.. textareas are a bit weird sometimes... and try use Request.Form instead of just Request

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334
    I tried that, and it did have a value. So that isn't the issue either... The Request.Form idea also didn't want to work. This is very irritating. I apprecaite your help, and hope we can solve this!

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334
    It turned out that the fieldname was Text, which is also an Access keyword, so that's what caused the error. As soon as I changed the fieldname, it worked. Thanks for your help.

Posting Permissions

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



Click Here to Expand Forum to Full Width