Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

VBS Script: Error - The text, ntetxt, and image data types cannot be compared or sorted

I am using a VBS script to collect a hardware inventory - I have a database HardwareInventory on SQL 2000 which it should add fields & records to.  My problem is it is failing on the last line "myMS2.Open countSQL, myConn, 3,1" line below, giving the error: "The text, ntetxt, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator", Code 80040E14.  - I have pasted the code preceding it .

The Hardware table contains 2 fields, hardware (text, 16) and strComputer (text, 16).

myConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=HardwareInventory;Data Source=sifirlsql1"
countSQL = "SELECT COUNT(*) as hits FROM hardware where strComputer = '" & strComputer & "'"
strSQL = "SELECT * FROM hardware WHERE strComputer = '" & strComputer & "'"
set myMS2 = CreateObject("ADODB.RecordSet")
set myMS = CreateObject("ADODB.RecordSet")
myMS2.Open countSQL, myConn, 3,1
0
MgtStack
Asked:
MgtStack
1 Solution
 
TDSnetCommented:
It's exactly as the error message describes.  The field you are comparing "strComputer" is of the Text data type.  This field cannot be used in a comparison using the "=" operator.  Try changing your SQL statement to the following:

countSQL = "SELECT COUNT(*) as hits FROM hardware where strComputer LIKE '" & strComputer & "'"

That should work.

Cheers,
Jack
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now