Making a Z39.50 Request via COM

Dim lobj_Z3950 
Dim lstring
Dim sfilename
sfilename = "output.mrc"
Set lobj_Z3950 =createObject("MARCEngine5.Query")
lobj_Z3950.Database = "LCDB_MARC8"
lobj_Z3950.Host = "lx2.loc.gov"
lobj_Z3950.Port = 210
lobj_Z3950.Syntax = "MARC21"
lobj_Z3950.Start = 0
lobj_Z3950.Limit = 1
lstring = lobj_Z3950.Z3950Search("@attr 1=4 " + chr(34) + "building digital libraries" + chr(34), -1)
Set lobj_Z3950 = Nothing
'show the record
msgbox(lstring)
bsuccess = Write2File(sfilename, lstring, false)
'if this was to be used in production
'i would include some error trapping.
Function Write2File(sfile, srecord, boverwrite)
Dim objStream
Set objStream = CreateObject("ADODB.Stream")
objStream.CharSet = "utf-8"
objStream.Open
objStream.WriteText srecord
if boverwrite = true then
' overwrite file
objStream.SaveToFile sfile, 2
else
' Just append
objStream.SaveToFile sfile, 1
end if
Write2File = true
End Function