Connecting to MS-SQL

AutoIT sample code - Connecting to a Microsoft SQL database server

C05348A3-9AB8-42C9-A6E0-81DB3AC59FEB
           

AutoIT sample code - Connecting to a MS-SQL database server:

;===============================================================================
; Description:		Connecting to a MS-SQL database server
; Author(s):		Videre Research, LLC - http://videreresearch.com
;===============================================================================
 
$sqlCon = ObjCreate("ADODB.Connection")  
$sqlCon.Open("Provider=SQLOLEDB;Data Source=change_me_server_name;Initial Catalog=change_me_database_name;Connect Timeout=150;Network Library=dbmssocn; User ID=change_me; Password=change_me;")  
IF IsObj($sqlCon) then  
 
    $rs = ObjCreate( "ADODB.RecordSet" )  
    $rs.Open( "SELECT * from change_me_table_name where last_updated > '" & @MON&"/"&@MDAY&"/"&@YEAR & "' order by last_updated", $sqlCon )  
 
   $recordcount =0  
    While $rs.eof <> TRUE  
 
    ConsoleWrite($rs.Fields( "userid" ).Value & @CRLF)  
    ConsoleWrite($rs.Fields( "log_results" ).Value & @CRLF & @CRLF)  
 
    for $x in $rs.Fields  
       ConsoleWrite($x.name)  
       ConsoleWrite(" = ")  
       ConsoleWrite($x.value & @CRLF)  
    next  
 
        $recordcount +=1  
        $rs.MoveNext  
    WEnd  
   $rs.Close  
   $sqlCon.Close  
   ConsoleWrite($recordcount & @CRLF)  
EndIf
Commentaires publiés : 0