I开发者_运维问答 want to do database operations in AutoIt. I written some code for it, but it is not working:
Global $adCN
$adCN = ObjCreate ("ADODB.Connection") ; <== Create SQL connection
$adCN.Open ("DRIVER={SQL Server};SERVER=sqlstaging;DATABASE=NivioAsia2;uid=niviodbstaging;pwd=niviodbstaging;") ; <== Connect with required credentials
if @error Then
MsgBox(0, "ERROR", "Failed to connect to the database")
Exit
Else
MsgBox(0, "Success!", "Connection to database successful!")
EndIf
$sQuery = "select * from irws_m_users where n_userid=10318583224314"
$adCN.Execute($sQuery)
$adCN.Close ; ==> Close the database
Exit
How can I get data from table using AutoIt?
It's done now...
$constrim="DRIVER={SQL Server};SERVER=sqlstaging;DATABASE=NivioAsia2;uid=niviodbstaging;pwd=niviodbstaging;"
$adCN = ObjCreate ("ADODB.Connection") ; <== Create SQL connection
$adCN.Open ($constrim) ; <== Connect with required credentials
MsgBox(0,"",$constrim )
if @error Then
MsgBox(0, "ERROR", "Failed to connect to the database")
Exit
Else
MsgBox(0, "Success!", "Connection to database successful!")
EndIf
$sQuery = "select * from irws_m_users where n_userid=10318583224314"
$result = $adCN.Execute($sQuery)
MsgBox(0, "", $result.Fields( "s_username" ).Value)
$adCN.Close ; ==> Close the database
精彩评论