April 22, 2005 at 11:22 am
For a project assigned to me, there's a need to access a ms-sql database from VBScript for the purpose of running a select query.
In my search using google to find helpful information I can only find stuff related to using an access database, which is not an option for this project.
So I decided to try the next best thing, try to use some code from on of my VB Projects which works fine in VB, unfortunately it doesn't work for me in VBScript.
Here are the first few lines, which it pukes on, someone please help me! What I am doing wrong here?
Dim oConn As New ADODB.Connection
Dim oRS As ADODB.Recordset
Dim strSQL As String
Con.CommandTimeout = 0
Con.CursorLocation = adUseClient
Con.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDatabase;Data Source=MyDataServer"
April 22, 2005 at 12:18 pm
Dim oConn 'can't use as in vbs
Dim oRS
Dim strSQL
set OConn = CreateObject("ADODB.Connection")
set oRS = CreateObject ("ADODB.Recordset")
oConn.CommandTimeout = 0
oConn.CursorLocation = 3 'adUseClient
oConn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDatabase;Data Source=MyDataServer"
oRS.Open "Select count(*) as Total from dbo.SysObjects", oConn, 1, 3 'look up the recordset options and find their numeric values
msgbox oRS.Fields("Total").Value
oRS.Close
set oRS = nothing
oConn.Close
set oConn = nothing
April 22, 2005 at 1:20 pm
Thank you!
This fills the gap I was needing perfectly.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy