Groups | Blog | Home
all groups > inetserver asp db > may 2005 >

inetserver asp db : ADODB.Field error '800a0bb9' - Working with SQL Server ntext fields


Derek Erb
5/19/2005 2:44:21 PM
I can't get past this one. I am trying to import an ntext column from
one SQL Server table to another.

Set RS = Conn.Execute("SELECT * FROM COLL")

do while not RS.EOF
Set RSOut = Conn.Execute("SELECT ImageNotes FROM Images WHERE
(Inventory='" & RS("Inventory") & "')")
if not RSOut.EOF then
lngFS = RS("Notes").ActualSize
if (lngFS) then
strTxt = RS.Fields.Item("Notes").GetChunk(lngFS)
RSOut("ImageNotes").AppendChunk strTxt
end if
end if
RS.MoveNext
loop

MY CODE DIES AT THE CALL TO GETCHUNK

I get the following error:

ADODB.Field error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.

Both columns are of the type ntext in both tables.

I can't figure out what to try next.

Help!
Mark J. McGinty
5/19/2005 5:23:01 PM

[quoted text, click to view]

Not to detract from what Bob said (it's all good advice) but there's another
obvious problem: connection.Execute always returns a firehose
(fwd-only/read-only cursor.) Calling AppendChunk is therefore problematic
on any of that recordset's field objects. (The error that results is, I'd
agree, less than forthcoming.)

-Mark




[quoted text, click to view]

Bob Barrows [MVP]
5/19/2005 6:26:22 PM
[quoted text, click to view]

This is probably the problem. You should avoid using selstar (Select *).
Always name the columns you are retrieving. However, see below for a better
idea.

[quoted text, click to view]

Are both these tables on the same SQL Server box? If so, you can use an
UPDATE statement, even if the tables are in different databases.:

sSQL = "UPDATE i SET ImageNotes = c.Notes " & _
"FROM Images i INNER JOIN COLL c ON i.Inventory=c.Inventory"


Or, the more ANSI-compliant version:

sSQL = "UPDATE Images SET ImageNotes = (SELECT " & _
Notes FROM COLL WHERE Inventory = Images.Inventory)"

Either way, simply execute it as:

Conn.Execute sSQL,,1

No need for cursors.

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Derek Erb
5/20/2005 4:27:52 AM
Bob,

Thank you so much for your very helpful and detailed reply.

I definitely like the ANSI-compliant pure SQL version especially as my
tables are all in the same database.

I tried executing "UPDATE Images SET ImageNotes = (SELECT Notes FROM
COLL WHERE (Inventory=Images.Inventory))" and I got the following
error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Driver][SQL Server] The text, ntext, and image
data types are invalid in this subquery or aggregate expression.

I feel like I'm back to stage one in that I know have an excellent SQL
command to do the import but I am still blocking on the fact that my
column is an ntext column.

I truly appreciate your assistance and hope that this is just something
stupid I'm doing wrong.

Thanks.
Derek Erb
5/20/2005 8:13:44 AM
Bob,

Thank you again for your extremely helpful reply.

The T-SQL version works absolutely perfectly. It certainly doesn't
both me as most of my triggers are in T-SQL as well.

Thank you for your help.
Bob Barrows [MVP]
5/20/2005 8:19:21 AM
[quoted text, click to view]

Oops. Good catch. I did miss that one.

Now I need to investigate why the UPDATE statement is failing ...

Bob

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Bob Barrows [MVP]
5/20/2005 8:50:15 AM
[quoted text, click to view]

Well that's a surprise. I'm going to have to try some tests. I was unaware
of this restriction.
[...]

Well, the good news is that the proprietary Transact-SQL syntax works fine:
sSQL = "UPDATE i SET ImageNotes = c.Notes " & _
"FROM Images i INNER JOIN COLL c ON i.Inventory=c.Inventory"

I do not know of any way to allow the pure SQL version to work in SQL
Server. You may wish to try one of the SQL Server groups: I suggest
m.p.sqlserver.programming

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Bob Barrows [MVP]
5/20/2005 8:53:02 AM
[quoted text, click to view]
Oh! I forgot to mention: the restriction against ntext columns in subqueries
IS documented in BOL:

Subquery Rules
A subquery is subject to a number of restrictions:

<snip>
The ntext, text and image data types are not allowed in the select list of
subqueries.

I had forgotten about that one ...

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

AddThis Social Bookmark Button