Note that there are some explanatory texts on larger screens.

plurals
  1. POInsert long string into Access DB using parametrised query in classic ASP
    text
    copied!<p>I'm trying to update a classic ASP application and as part of the update I've tried to replace dynamic SQL using string concatenation with a parametrised query.</p> <p>The problem is that the parameters won't accept a value which is longer than 210 characters.</p> <p>I get the following error...</p> <blockquote> <p>ADODB.Parameter error '800a0d5d'</p> <p>Application uses a value of the wrong type for the current operation.</p> <p>/admin/Save_product_subcategories.asp, line 30</p> </blockquote> <p>My first attempt looks like this...</p> <pre><code>SQLString = "UPDATE Product_SubCategories SET SubCategory=?, Description=? WHERE SubCategoryID=?" Set courseCommand = Server.CreateObject("ADODB.Command") courseCommand.ActiveConnection = objConn courseCommand.CommandText = SQLString courseCommand.Parameters(0).value = cleanCategory courseCommand.Parameters(1).Value = cleanDescription courseCommand.Parameters(2).value = cleanSubCategoryId </code></pre> <p>I've tried manually setting the parameter type and increasing the size of the parameter...</p> <pre><code>courseCommand.Parameters(1).Type = 203 courseCommand.Parameters(1).Size = 300 courseCommand.Parameters(1).Type = adLongVarWChar </code></pre> <p>I've also tried creating a parameter with the command.CreateParameter method but that gives the same error.</p> <pre><code>param = courseCommand.CreateParameter(,,,,cleanDescription) 'or param = courseCommand.CreateParameter(,adLongVarWChar,,,cleanDescription) 'or param = courseCommand.CreateParameter(,adLongVarWChar,,300,cleanDescription) courseCommand.Parameters(1) = param </code></pre> <p>I'm beginning to think that my only option is to go back to dynamic sql.</p> <p>Edit:</p> <p>I tried to Append the parameter instead of adding it to the collection using the array index but none of the parameters worked after that.</p> <blockquote> <p>Provider error '80020005'</p> <p>Type mismatch.</p> <p>/admin/Save_product_subcategories.asp, line 31</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload