vbs连接sql server

 

Function connMMSQL(ip,user,pwd,database,strsql)
	Dim conn,Re,arr(2)
	set conn = CreateObject("ADODB.Connection")
	conn.ConnectionString="Provider=SQLOLEDB.1;Password="+pwd+";Persist Security Info=True;User ID="+user+";Initial Catalog="+database+";Data source="+ip   
	conn.Open
	If conn.state=0 Then
		arr(0) = -1  
	    connMMSQL = arr
	ElseIf conn.state=1 Then
	   set Re =  conn.execute(strSql)
	   If Re.EOF = False Then 
	   	arr(0) = 1
	   	arr(1) = Re.GetRows
	   	connMMSQL = arr
	   ElseIf Re.EOF = True Then 
	   	arr(0) = 0
	   	connMMSQL = arr
	   End If 	   	
	End If
	conn.close
	Set conn = Nothing
End Function 

 

  

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。