Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to use Windows Script Host to call ADO

364 views
Skip to first unread message

PacBell

unread,
Sep 7, 2000, 12:37:09 PM9/7/00
to
Does anyone know if it is possible to make an ADO call in '.vbs' file using windows script host. Currently the '.vbs' runs
but it doesn't insert data into SQL. No errors result...a SQL trace was performed and the SQL command when copied (from SQL Trace file) and ran in SQL Tools works fine. Not sure if the ADO call is correct. The same VBscript works through an ASP web page, but not when called through the Command Prompt. Here's the code:
 
Dim Conn, Command
  Set Conn = Wscript.CreateObject("ADODB.Connection")
  Conn.ConnectionTimeout = 15
  Conn.CommandTimeout = 30
  Conn.Open "DSN=DSNName;Description=Description;SERVER=(local);UID=uid;PWD=pwd;APP=Microsoft (R) Developer Studio;WSID=Server;DATABASE=Database;StatsLog_On=Yes", "uid", ""
  Set Command = Wscript.CreateObject("ADODB.Command")
  Set Command.ActiveConnection = Conn
 
Set rsResults = Wscript.CreateObject("ADODB.Recordset")
   Command.CommandText = "dbo.""Insert_Data"""
   Command.CommandType = 4
   Set Command.ActiveConnection = Conn
   Set tmpParam = Command.CreateParameter("@Dealer_ID", 129, 1, 20, [strDealerID])
  
   Command.Parameters.Append tmpParam
   rsResults.Open Command, , 0, 1

Any help is greatly appreciated.

Thanks,
 
Albert Frausto
MAYA Marketing & Internet
ma...@mayaco.com
www.californiamall.com

Chad Myers

unread,
Sep 7, 2000, 1:37:13 PM9/7/00
to
 
The short answer is: Yes, ADODB an all it's classes are supported in WSH.
 
WSH is a script host (ergo Windows "scripting host") just like ASP.
ADODB is a COM object which is accessible by all COM consumers (VB, VC++,
VJ++, VFP, VBA, VBScript, JScript, et al)
 
From what I see, it doesn't look like you're doing anything wrong.
Your way of running a SP is a little weird, but it doesn't look wrong.
 
About the script not working in WSH but in ASP, are the scripts being run
from the same machine?
 
Try using this for your Conn.Open:
 
Conn.Open "DSN=DSNName;UID=username;PWD=password;"
 
Also, instead of doing:
rsResults.Open Command, ,0,1
try:
Set rsResults = Command.Execute
 
 
-Chad
"PacBell" <ma...@mayaco.com> wrote in message news:eL4O8mOGAHA.246@cppssbbsa05...

Michael Harris

unread,
Sep 7, 2000, 7:48:16 PM9/7/00
to

Code-wise, there is no difference between using ADO in a WSH hosted VBScript
and an ASP hosted script, assuming you provide the WSH version with the
necessary named constant values (i.e., what's in adovbs.inc). The only real
difference is how you display results, not how you access the ADO object
model...

--
Michael Harris
Microsoft.MVP.Scripting
--

"PacBell" <ma...@mayaco.com> wrote in message

news:O1jnQ#QGAHA.252@cppssbbsa05...
> Thanks for your response.
>
> I have the latest MDAC update and ADO is registered.
>
> We've never tried running a script using ADO with WHS before either. Not
> sure what it could be.
>
> "Jon Butler" <jmbu...@southeast.net> wrote in message
> news:itRt5.12489$RY2....@news4.mco...
> > Could it be that the machine you're running the script on doesn't have
ADO
> > registered? Maybe you need to install an MDAC update or find some other
> > method of registering ADO.
> >
> >
> >
>
>

0 new messages