Solved

Can I read data from sql server using vbscript?

Posted on 2008-09-30
2
1,553 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

679 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