VBS访问SQL数据库

'#######################################################################################
'功能:VBS访问SQL数据库

dim conn

set conn=WScript.CreateObject("ADODB.Connection")

conn.Open "Driver={SQL server};server=192.168.1.1;database=mydb;uid=myuser;pwd=mypwd;"

 

dim rst

set rst=WScript.CreateObject("ADODB.Recordset")

sSQL="select * from ......"

 

rst.open sSQL,conn,1,1

if rst.eof and rst.bof then

    WScript.Echo "没有记录"

else

    do while not rst.eof

        WScript.Echo rst("Field1") & " " & rst("Field2")

        rs.movenext

    loop

end if

 

WScript.QUIT

rst.close

set rst=nothing

 

conn.close

set conn=thing

你可能感兴趣的:(sql)