We help IT Professionals succeed at work.
Get Started

Getting Data With VBScript

reidy_boy
reidy_boy asked
on
796 Views
Last Modified: 2008-01-09
Hi, this is probably an easy one as I am new to this area.  I am trying to use VBScript to extract the contents of a table from a database which is being hosted by a Microsoft SQL service, and put it into a csv file.

My (unfinished) script thus far reads as follows:
------------------------ C:\Admin\Scripts\Test.vbs ------------------------
Set oServer = CreateObject("SQLDMO.SQLServer")

oServer.LoginSecure = True
oServer.Connect "."

Set oDatabase = oServer.Databases("Harris")
oDatabase.ExecuteImmediate("SELECT * FROM NSTUPERSONAL")
--------------------------------------------------------------------------------

When I run this script I get the following Windows Script Host error message:
--------------------------------------------------------------------------------
Script: C:\Admin\Scripts\Test.vbs
Line: 7
Char: 1
Error: [Microsoft][ODBC SQL Server Driver]Invalid object name 'NSTUPERSONAL'.
Code: 800A00D0
Source: Microsoft SQL-DMO (ODBC SQLState: 42S02)
--------------------------------------------------------------------------------

However, I know the table NSTUPERSONAL exists so it must be something else.  I suspect I have not connected to the database properly.  Some pointers in the right direction would be most helpful.  I am running the script locally.
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE