TheCarver
TheCarver

Reputation: 19733

Classic ASP/MySQL - Parameter Issue

I have been trying to insert a huge text-editor string in to my database. The application I'm developing allows my client to create and edit their website terms and conditions from the admin part of their website. So as you can imagine, they are incredibly long. I have got to 18,000+ characters in length and I have now received an error when trying to add another load of text.

The error I am receiving is this:

ADODB.Command error '800a0d5d'
Application uses a value of the wrong type for the current operation

Which points to this part of my application, specifically the Set newParameter line:

Const adVarChar = 200
Const adParamInput = 1
Set newParameter = cmdConn.CreateParameter("@policyBody", adVarChar, adParamInput, Len(policyBody), policyBody)
cmdConn.Parameters.Append newParameter

Now this policy I am creating, that is currently 18,000+ characters in length, is only half complete, if that. It could jump to 50 - 60,000! I tried using adLongVarChar = 201 ADO type but this still didn't fix it.

Am I doing the right thing for such a large entry? If I am doing the right thing, how can I fix this issue? ...or if I'm doing the wrong thing, what is the right one?

Upvotes: 0

Views: 675

Answers (1)

Tony Hopkinson
Tony Hopkinson

Reputation: 20330

Try to avoid putting documents in your database if you can. Sometimes it's a reasonable compromise, serialised objects, mark up snippets and such. If you don't want to query the document with sql the only benefit is the all in one place thing. ie back up your db, you back up your documents as well, and you can use your db connectivity exclusively.

That said nothing is free, carting all that stuff about in your database costs you.

If you can. have a documents table, User name for the file, and internal name in your documents directory, so the file name is unique in the file system, and a path description, if there could be more than one. Then just upload and download the selected document as a file, on a get or set of the related database entity. You'll need to dal with deployment issues, document directory exists, and the account you are running mysql daemon as can see it, but most of the time, the issues you have keeping documents seperate fromthe db, are much easier to deal with than the head scratchers you are running into now.

Upvotes: 1

Related Questions