Solved

Can I read data from sql server using vbscript?

Posted on 2008-09-30
2
1,549 Views
Last Modified: 2012-05-05
I'm just getting started with script programming and want to verify that I can use vb script to read data from sql server.  I am testing by trying to open the 'pubs' database.  

on error resume next
'msgbox "start"
Set con = CreateObject("ADODB.Connection")
constring = "Provider=SQLOLEDB.1; Data Source=mydatasource; Initial Catalog=Pubs; user id = sa; password=''"
con.open = constring
msgbox err.description
msgbox "end"

I get the error "SQL Server does not exist or access denied".
Should this work?
0
Comment
Question by:utahalee
2 Comments
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 50 total points
ID: 22605799
If you have no password, you don't need two single quotes at the end ''.  Also, please don't tell me that your SA account has no password.

Also, remove the spaces before and after the = in user id.  
0
 

Author Closing Comment

by:utahalee
ID: 31501632
There is no sql administrator.  They have one app that was written by a contractor a few years ago.  They have no programmer, no database administrator,  just 1 network person for the whole it dept.  This app is completely unsupported.  I work partime as the it asst.  I have done lots of visualstudio vb programming and have been asked to try to do some reporting from the database.    There is no one here who know anything about sql server except that it is being used.  I'm not a dql server administrator so I'm taking "educated" guesses on the connection string.  I'm testing with the pubs.  it has an "sa" user which I'm guessing has no password but not sure.   My main question was that I wanted to be sure that I could could us vb script like in my example and make a connection which I did not hear you say won't work.  Its a mess trying to figure out what do use because noone here knows how it works,  Just getting a connection will be a giant leap.  Thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to count occurrences of each item in an array.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now