vbscript - ADODB reference from an HTA application -
i need hta application shows data mdb
using ado
technology.
here's how code starts:
function getdata() dim pathname pathname = "d:\\wp\\ado\\adoexamples.mdb" dim con 'as new adodb.connection dim rs 'as new adodb.recordset set rs = new adodb.recordset rs.cursortype = adopenstatic rs.locktype = adlockoptimistic set con = new adodb.connection
i error:
class undefined adodb.
apparently, it's because need include adodb references. how do in .hta
file?
you can't create ado objects way in vbscript. use createobject()
instead:
pathname = "d:\\wp\\ado\\adoexamples.mdb" dim con 'as new adodb.connection dim rs 'as new adodb.recordset set rs = createobject("adodb.recordset") rs.cursortype = adopenstatic rs.locktype = adlockoptimistic set con = createobject("adodb.connection")
also, vbscript doesn't recognize ado named constants adopenstatic
or adlockoptimistic
, need define them yourself:
const adopenstatic = 3 const adlockoptimistic = 3
or use numeric value.
Comments
Post a Comment