Skip to content

Instantly share code, notes, and snippets.

@jiaming0708
Created July 31, 2017 07:19
Show Gist options
  • Save jiaming0708/8b1dc80dd8736f6015fd9768e6a08f5a to your computer and use it in GitHub Desktop.
Save jiaming0708/8b1dc80dd8736f6015fd9768e6a08f5a to your computer and use it in GitHub Desktop.
vba
Private Function CheckCompanyExist(comp As String, mac As String) As Boolean
Dim result As Boolean
Dim ADOcn As New ADODB.Connection
Dim ADOrt As New ADODB.Recordset
Dim strCn As String
Dim strSQL As String
strCn = "Provider=SQLOLEDB;Server=eshclouds-license******;Database=License;Uid=******;Pwd=*****;"
strSQL = "select * from ComanyInfo"
With ADOcn
.ConnectionString = strCn
.Open
Set ADOrt = .Execute(strSQL)
End With
Set ADOrt = ADOcn.Execute(strSQL)
If ADOrt.RecordCount > 0 Then
MsgBox ("有查詢到資料")
Else
MsgBox ("找不到資料")
End If
ADOrt.Close
ADOcn.Close
CheckCompanyExist = result
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment