Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Query a SQL server from VBScript

Posted on 2009-07-15
1
Medium Priority
?
864 Views
Last Modified: 2012-05-07
Is it possible to Query a SQL server from VBScript, get the sql server to return a boolean value to the vbscript and then use an if statement in the VBScript to act upon that returned value?
0
Comment
Question by:ict-torquilclark
[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
1 Comment
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 24865944
Certainly...some sample code for you - of course, you'll need to adjust it to your criteria
If GetBoolean Then
  'Execute some code for a true return
Else
  'Execute otherwise
End If
 
Function GetBoolean()
Dim conn : Set conn = CreateObject("ADODB.Connection")
strCnx = "Driver={SQL Server];Server=SQL-Server7;Database=MyDatabase;user id=SomeID;password='password';" 'You can also use trusted connection...
conn.Open strCnx
Dim cmd : Set cmd = CreateObject("ADODB.Command")
Set cmd.ActiveConnection = conn
 
Dim rs : Set rs = CreateObject("ADODB.RecordSet")
rs.Open "Select MyBoolean From Table1 Where ValueData = SomeCriteria", conn
 
If Not rs.EOF Then GetBoolean = True
rs.Close
End Function

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

610 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