![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Log off Script I am going to setup a log off script. It will connect to a database and update a record ... 'Create an instance of the ADO connection and recordset objects Set Connection = Server.CreateObject("ADODB.Connection") Set Recordset = Server.CreateObject("ADODB.Recordset") 'Open the connection to the database Connection.Open "DSN=INTRANET" My question is where the DSN has to be? On the Client? or On the Server? Our workstations as part of a windows 2003 domain controller. Thank you all Bre-x |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Log off Script "Bre-x" <cholotron@xxxxxx> wrote in message news:%239vK5J$0JHA.2516@xxxxxx Quote: >I am going to setup a log off script. It will connect to a database and >update a record ... > > 'Create an instance of the ADO connection and recordset objects > Set Connection = Server.CreateObject("ADODB.Connection") > Set Recordset = Server.CreateObject("ADODB.Recordset") > > 'Open the connection to the database > Connection.Open "DSN=INTRANET" > > My question is where the DSN has to be? On the Client? or On the Server? > Our workstations as part of a windows 2003 domain controller. > > Thank you all > > Bre-x would need to be on the client, just as if the user ran the script themselves. When I run scripts that use ADO I don't use DSN's. My connection string specifies the server, driver, etc. You can search on the web for example connection strings. For SQL server (using Windows integrated authentication) I use a string similar to: strConnect = "DRIVER=SQL Server;" _ & "Trusted_Connection=Yes;" _ & "DATABASE=MyDatabaseName;" _ & "SERVER=MyServer\MyInstance" adoConnection.ConnectionString = strConnect For Microsoft Access I use a string similar to: strConnect "DRIVER=Microsoft Access Driver (*.mdb);" _ & "FIL=MS Access;DriverId=25;" _ & "DBQ=c:\databases\MyDB.mdb;" -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Log off Script Thank you for your help. Now my script is giving me a Type Mismatch error ![]() ' Dim Variables '----------------------- Dim conn Dim sql Dim objNetwork Dim CC ' Set Database Connection '------------------------ Set conn = CreateObject("ADODB.Connection") conn.open "DSN=INTRANET" Set rs = CreateObject("ADODB.Recordset") ' Get User Name '------------------------ Set objNetwork = CreateObject("WScript.Network") ' Count Records '------------------------ sql = "SELECT count(*) as CC FROM sys_user WHERE user_name='" & objNetwork.UserName & "'" rs.Open sql, conn, 3, 3 CC = rs.Fields(0).Value if CC = 1 Then 'Update Table Query '------------------------ sql = "UPDATE sys_user SET last_logoff = '" & Now & "' WHERE user_name='" & objNetwork.UserName & "'" conn.Execute sql else 'Insert Record '------------------------ sql = "INSERT INTO sys_user (user_name, user_ip, user_pc, last_login, last_logoff) 'VALUES ('" & objNetwork.UserName & "', '0.0.0.0', 'none','none','" & Now & "')" conn.Execute sql end if ' Close Connections '------------------------ conn.close Set rs = Nothing Set conn = Nothing |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Log off Script CC = cint(rs.Fields(0).Value) Sorry. I am very new at this. thank you all |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Log off Script Please include the older postings, too. Thanks. "Bre-x" <cholotron@xxxxxx> wrote in message news:uHleouA1JHA.5440@xxxxxx Quote: > CC = cint(rs.Fields(0).Value) > > Sorry. I am very new at this. > > thank you all > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Logon Script Causing Laptops To Hang - Problems in script? | VB Script | |||
| problem passing args to script 'There is no script engine for file extenstion' | VB Script | |||
| Include another script, keep variables in included script? | PowerShell | |||
| Script file has 'OS Handle' error when run from script | PowerShell | |||
| Can you drag-n-drop a file on top of a PS script to run the script? | PowerShell | |||