?
Solved

Can I read data from sql server using vbscript?

Posted on 2008-09-30
2
Medium Priority
?
1,558 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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…
Suggested Courses

650 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