PDA

Click to See Complete Forum and Search --> : writing textarea to database


spandex44
Jul 14th, 2001, 11:20 AM
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:

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

CreoN
Jul 14th, 2001, 12:32 PM
It would be easier if you gave us some code we could look at...

spandex44
Jul 14th, 2001, 12:55 PM
Here's the entire code for that page:

<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

CreoN
Jul 14th, 2001, 01:05 PM
Try this instead...


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") & "')")

spandex44
Jul 14th, 2001, 01:11 PM
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.

CreoN
Jul 14th, 2001, 01:22 PM
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

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

spandex44
Jul 14th, 2001, 02:28 PM
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!

spandex44
Jul 14th, 2001, 08:02 PM
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.