Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid string or buffer length - why?

Status
Not open for further replies.

mopacfan

Programmer
Oct 30, 2000
190
0
0
US
I'm migrating from mssql to mysql due to the cost of licensing with macrosoft. Most of the sql statements in my application have transferred without any problem. However, when I do a recordset addnew and then update on this one page, I get "Invalid string or buffer length".

Here is the addnew code:

Code:
set rsCart = server.CreateObject("adodb.recordset")
rsCart.Open "tblCartItems",objConn,3,3
rsCart.AddNew
rsCart("CartID") = session("cart")
rsCart("ItemID") = ProdID
rsCart("Quantity") = Quant
if rsCart(&quot;PlasticColor&quot;) <> &quot;&quot; Then rsCart(&quot;PlasticColor&quot;) = PlasticColor
rsCart(&quot;ShapeNum&quot;) = shape
rsCart(&quot;Sides&quot;) = numsides
rsCart(&quot;NumInksA&quot;) = numInksa
if numInksB <> &quot;&quot; Then rsCart(&quot;NumInksB&quot;) = numInksB
rsCart(&quot;InkColor1&quot;) = inkcol(1)
rsCart(&quot;InkColor2&quot;) = inkcol(2)
rsCart(&quot;InkColor3&quot;) = inkcol(3)
rsCart(&quot;InkColor4&quot;) = inkcol(4)
rsCart(&quot;InkColor5&quot;) = inkcol(5)
rsCart(&quot;InkColor6&quot;) = inkcol(6)
rsCart(&quot;InkColor7&quot;) = inkcol(7)
if numInksB > 0 Then
    rsCart(&quot;InkColorB1&quot;) = inkcol2(1)
    rsCart(&quot;InkColorB2&quot;) = inkcol2(2)
    rsCart(&quot;InkColorB3&quot;) = inkcol2(3)
    rsCart(&quot;InkColorB4&quot;) = inkcol2(4)
    rsCart(&quot;InkColorB5&quot;) = inkcol2(5)
    rsCart(&quot;InkColorB6&quot;) = inkcol2(6)
    rsCart(&quot;InkColorB7&quot;) = inkcol2(7)
end if
delim = instr(Opt,&quot;,&quot;)
if instr(Opt,&quot;,&quot;) Then rsCart(&quot;OptName&quot;) = left(Opt,delim - 1)
if instr(Opt,&quot;,&quot;) Then rsCart(&quot;OptPrice&quot;) = mid(Opt,delim + 1)
rsCart(&quot;Comments&quot;) = comments
rsCart(&quot;PMSCharge&quot;) = PMSCharge
rsCart.Update 
rsCart.close
set rsCart = nothing

Does anyone else have experience with mysql to know why this may be bombing out?

Thanks
 
Is it a particular field in the database that doesn't like the string?

I would check the data type of the field you're trying to update and the data type of the variable you're trying to pass. Sometimes you can run into situation where a Unicode-formatted or ANSI-formatted string won't work with your new database. If the MSSQL field has data type NVARCHAR and you're using VARCHAR(50) in MySQL that might cause probelms,
it's just an example though.

I found this post on the net, maybe it'll help,

Typically, this is caused by trying to insert too many characters into a defined column. For example:

CREATE TABLE #foo (bar CHAR(5))
INSERT #foo(bar) VALUES('yoohoo')
A couple of easy fixes include:
using client-side methods (e.g. MAXLENGTH or JavaScript) to prevent such data from being submitted; adjusting the column definition(s) to accommodate for likely data lengths; adjusting the incoming data to fit the column definition, e.g.:

<%
bar = replace(left(request.form(&quot;bar&quot;),5),&quot;'&quot;,&quot;''&quot;)
sql = &quot;INSERT #foo(bar) VALUES('&quot; & bar & &quot;')&quot;
' ...
%>
hopefully that should help.
dbalsdon

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top