Solved

Problem connecting to sql server  using vbscript

Posted on 2008-10-02
4
487 Views
Last Modified: 2012-05-05
I receive the following error message :
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
in err.description and con.state = 0 which I thought meant no problems for con.open statement.

I am using the computer name  found in the properties of "My Computer" of the server that is running sql server for the  "server=" in the connection string.  Not sure if that may be the problem.  I get the same error with both connection strings in the code below.

here is the code snippet:

on error resume next
Set con = CreateObject("ADODB.Connection")
'constring = "Provider=SQLOLEDB.1; server=uta-treatlink; database=totalh; uid=xxxx; pwd=xxxx'"
constring = "Driver={SQL Server}; server=uta-treatlink; database=totalh; uid=xxxx; uid=xxxx"

con.connectionstrong = constring
con.open
msgbox err.description & "  (state = " & con.state & ")"

cnt = 0
Set rs = CreateObject("ADODB.Recordset")
rs = con.Execute ("Select * from xxx")
do until rs.EOF
   cnt =  cnt + 1
loop

set rs = nothing
con.close
set con = nothing

msgbox ("count = " & cnt)

-------------

this seems too simple to not be working.  
Thanks
0
Comment
Question by:utahalee
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:JMT116
ID: 22626025
Not sure if this will help, but in the uncommented constring uid appears twice.

Also depending on how the server is setup sometimes for server name you need to include this "myServerName\theSQLServerInstanceName".  
0
 

Author Comment

by:utahalee
ID: 22635258
Oops, didn't notice the uid in there twice. That typo is just in my snippet I posted.  
I still have the connection problem using "myservername".  How do I find the "\sqlServerInstanceName"?

This is a 1 1/2 person shop so there is no sql server administrator to ask.  The sql server database was setup by a contractor and has been running fine since.

Thanks for your help!

0
 
LVL 3

Accepted Solution

by:
JMT116 earned 100 total points
ID: 22636831
Use this reference to find the instance name.
http://support.microsoft.com/kb/265808

You should be able to find the instance name from the SQL Server Configuration Manager.
0
 

Author Comment

by:utahalee
ID: 22650548
Unforunately I have no experience with SQL Server Configuration Manager or setting up SQL Server.  This database was setup a few years by a contractor.  It has run on its own since then.  I have defined tables, columns, and stored procedures for a database and programmed to access the database but no administration.  A sql administrator has always given me the connection string info but there is not one here.  I looked at the link and it was for a sql adminstrator and not for me.  I am only familiar with query analyser and enterprise manager.  Can I find server="???" for the connection string from either one of those?
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Search for URL in string php 4 55
Catch Cancellation error from objShell.Run 10 68
Python Encoding Problem \u2013 4 87
inactive users 13 54
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
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.

744 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

13 Experts available now in Live!

Get 1:1 Help Now