?
Solved

Can I read data from sql server using vbscript?

Posted on 2008-09-30
2
Medium Priority
?
1,556 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 200 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

801 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