Archive for the VBScript Category

You already know how to run SQL queries on a database using ADO and VbScript, but what about stored procedures? The reasons why you might want to use a stored procedure vs. a SQL query is beyond the scope of this article. The decision has been made, and now you just have to make it work. Let’s get started:

(more…)

Popularity: 32% [?]

In order to connect to a database using an ADO object, you need a connection string. Here’s a simple way to get one in Windows, and all you need to do it is… your desktop.

New Text File
First, right-click on your desktop and create a new text file. It doesn’t matter what you name it, I usually keep mine as “New Text File”

 

UDL File
Next, rename your new file with a .UDL extension. Notice that when you do, the icon changes to something that ISN’T a text file.

 

(more…)

Popularity: 12% [?]

Part Two: Running the Query.

So we’ve created our ADO connection and opened it successfully. Now what?

First, we’ll need a query to run. This isn’t a tutorial on SQL, so I’ll just give you one… assigning it to a string for easy use.

Dim strSQL
strSQL="select * from customers where CustomerNum=098381"

For those who don’t speak SQL, the simple query above will return a list of customers that have the customer number 098381. Logically, this is PROBABLY a list of just one customer, but don’t get the impression that this will always be the case. (more…)

Popularity: 40% [?]

Part One: Making the ADO Connection

Usually, when a novice programmer hears the word “database” or “network” they break out in hives. They have the mistaken impression that connecting to a database, either locally or over a network, is difficult to do or involves some kind of esoteric commands that only more advanced programmers know how to use. Not true. The various flavors of Visual Basic have made this as easy as… well… reading this blog.

We’ll be using an ActiveX Data Object, which is commonly abbreviated as “ADO”. The process is called “Creating an ADO connection” to a database. Let’s jump right into the code, shall we?
(more…)

Popularity: 19% [?]