Cannot insert Large text into Database Memo field

O

Olaf Winterton

I'm trying to insert this text into a memo field:

Set cnn = CreateObject("ADODB.Connection")
str = Server.MapPath("database/alumni.mdb")
strDB = "Provider=MICROSOFT.JET.OLEDB.4.0;Data Source=" & str
cnn.Open strDB
Set rst = CreateObject("ADODB.Recordset")

sql = "INSERT INTO tblMessage (MessageID, UserID, PostTypeID, Subject,
DatePosted, MessageText, Active) Values ('" & vMessageID & "','" &
vUser & "', " & vPostType & ",'" & vSubject & "','" & vDatePosted &
"','" & vMessageText & "',0)"

rst.Open sql, cnn, adOpenStatic, adLockOptimistic

vMessageText = "This is a test just to see if it will blow up on a
large comment. Just testing again. Don't mind me."

Can I put this into my database field or is it too much and if not,
how do I solve this issue. I need to be able to post messages and
input for large fields.
 
A

Aaron Bertrand - MVP

Why are you using a recordset, and specifying cursors/locks? Recordsets are
for *retrieving* data, not affecting data. Change your rst open line to the
following:

cnn.execute sql, , 129

And get rid of the set rst = line.

If this does not work, post what "doesn't work" means.
 
O

Olaf Winterton

Thanks Aaron, that fixed my problem. Sorry for such a newbie problem.
That seemingly has solved the problem. For some reason I was having
trouble storing large text inputs with punctuation. I'm not sure about
apostrophes, but now commas, periods, and any other punctuations seem to
work. Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top