+ Post New Thread
Results 1 to 8 of 8
Scripts Thread, VBScript / SQL Server in Coding and Web Development; Anyone know how to get a VBScript to connect to a SQL Server (2000 or 2005) ? Looking for one ...
  1. #1

    Gatt's Avatar
    Join Date
    Jan 2006
    Posts
    6,658
    Thank Post
    858
    Thanked 646 Times in 429 Posts
    Rep Power
    498

    VBScript / SQL Server

    Anyone know how to get a VBScript to connect to a SQL Server (2000 or 2005) ?

    Looking for one to run during login & Logoff that will connect and be able to write info to a table on the sql server

    Working on a logon/Logoff tracker that has a .NET interface (which is running - sort of)

  2. #2

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,343
    Thank Post
    624
    Thanked 1,584 Times in 1,421 Posts
    Rep Power
    414

    Re: VBScript / SQL Server


  3. #3

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,154
    Thank Post
    114
    Thanked 527 Times in 450 Posts
    Blog Entries
    2
    Rep Power
    123

    Re: VBScript / SQL Server

    We use this in a script to record username, computername and IP to a SQL database - call it with appropriate parameters :-)

    The logoff does the same sort of thing but updates the last record for that user/computer pair - I can find the code if you need it :-)



    sub RecordLogon(sUsername,sComputername,sIP)
    dim sServer, sConn, oConn,oRS
    sServer="sqlservername"
    sConn="provider=sqloledb;data source=" & sServer & ";initial catalog=logoninfo"
    Set oConn = CreateObject("ADODB.Connection")
    oConn.Open sConn, "username", "secretpassword"
    Set oRS =CreateObject("ADODB.Recordset")
    sSQL="insert into logonoff(username,compname,ip,ontime) values('" & sUserName & "','" & sComputerName & "','" & sIP & "',getdate())"
    ors.open sSQL, oconn
    end sub

  4. Thanks to srochford from:

    Norphy (18th March 2011)

  5. #4

    Gatt's Avatar
    Join Date
    Jan 2006
    Posts
    6,658
    Thank Post
    858
    Thanked 646 Times in 429 Posts
    Rep Power
    498

    Re: VBScript / SQL Server

    Cheers Steve - wil give that a bash on Wednesday

  6. #5

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,037
    Thank Post
    209
    Thanked 425 Times in 306 Posts
    Rep Power
    144

    Re: VBScript / SQL Server

    Just found this script very useful!

    We're currently looking into ditching ranger and I'm looking for scripts that will replace some of the useful functions of ranger, such as finding out where a specific user has been logged on, which this script does perfectly for me! Now all I've got to do it write a simple PHP interface to allow me to search and report on the data!

    I'm also looking for a script or another way of getting a live report on my screen of who is logged on and where at that moment in time. At the moment lan ranger does this of course, but is there another way of doing this without lan ranger??

    Cheers,

    Mike.

  7. #6
    mrcrazy04's Avatar
    Join Date
    Nov 2006
    Location
    Bedfordshire/Cheltenham, UK
    Posts
    258
    Thank Post
    2
    Thanked 11 Times in 11 Posts
    Rep Power
    17

    Re: VBScript / SQL Server

    I use an a VBScript (in an HTA) which uses WMI, and Active Directory for all the computer names (which it pings to see if they're on).
    It's quite useful, as I definitely know who's on what machine when. I can also then log them off remotely

  8. #7
    Norphy's Avatar
    Join Date
    Jan 2006
    Location
    Harpenden
    Posts
    2,260
    Thank Post
    51
    Thanked 276 Times in 214 Posts
    Blog Entries
    6
    Rep Power
    113
    Sorry to bump ye olde post but would you mind posting the logoff bit as well please Steve?

    Cheers

  9. #8

    Join Date
    Sep 2011
    Posts
    16
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    last logon date/time + computer name

    Hello,

    I have a script that gives me some logon information (username, date and time at which they logged on), and I have a separate script that gives me the computer names. I am trying to merge those two scripts together, but I'm having a lot of trouble doing so. Would you be able to show me your code? Or if you want I can send you mine and you can give me some hints?

    Thanks


    Quote Originally Posted by mrcrazy04 View Post
    I use an a VBScript (in an HTA) which uses WMI, and Active Directory for all the computer names (which it pings to see if they're on).
    It's quite useful, as I definitely know who's on what machine when. I can also then log them off remotely

SHARE:
+ Post New Thread

Similar Threads

  1. VBScript IDE + Debugger
    By Geoff in forum Scripts
    Replies: 4
    Last Post: 13th September 2007, 08:56 PM
  2. VBScript Error
    By sqdge in forum Scripts
    Replies: 20
    Last Post: 13th September 2007, 03:34 PM
  3. another VBScript question!
    By StewartKnight in forum Coding
    Replies: 4
    Last Post: 3rd May 2007, 05:41 PM
  4. VBScript
    By StewartKnight in forum Coding
    Replies: 5
    Last Post: 1st May 2007, 11:04 AM
  5. vbscript arguements ?
    By mac_shinobi in forum Scripts
    Replies: 1
    Last Post: 20th February 2007, 10:29 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •