little vbscript help

Martin

Lifer
Jan 15, 2000
29,178
1
81
is it possible to connect to a database using vbscript only, without using ASP?

I am trying to write a little script to export data from an SQL server, but the locations I'm going to run it on won't necessarily have ASP so the usual way of connecting (Server.CreateObject ...) won't be possible, since Server is an ASP object
 

Noobsa44

Member
Jun 7, 2005
65
0
0
While this doesn't exactly answer your question, this might help a little. I tried to access a database I created a few years ago using VB Script. I ended up doing it some other way, however I kept part of the script that I was originally working on. I believe it was taken and converted from a VB6 example and I don't recall if it ever worked, but here it is:

Dim oConn 'As ADODB.Connection
Dim oRs 'As ADODB.Recordset
Dim sConn' As String
Dim sSQL 'as String

Set oConn = Server.CreateObject("ADODB.Connection")
Set oRs = Server.CreateObject("ADODB.recordset")

sConn = "Server=****;Database=Test;UID=******;PWD=*****;"'Removed server, username and password to protect the guilty.

' Open a connection.
Set oConn = New ADODB.Connection
oConn.Open sConn

' Make a query over the connection.
sSQL = "SELECT Password, UserName " & _
"FROM Table_1"
Set oRs = New ADODB.Recordset
oRs.Open sSQL, oConn

MsgBox oRs.RecordCount

' Close the connection.
oConn.Close
Set oConn = Nothing
 

KB

Diamond Member
Nov 8, 1999
5,406
389
126
Server.CreateObject is just a link to CreateObject, which is a function usable anywhere vbscript is usable.. i.e Windows Script Host, Word/Excel Macros

So take your code you were going to run in ASP, put it in a vbs file, remove server. from createobject and get rid of any code referring to response or server objects like response.write