I have created a vb script file to automatically upload invoices to AccPac. I am trying to insert a procedure that checks whether this invoices has already been uploaded. This is the code:
///////////////
Function CheckUploaded(ZRBRValue As String) As Boolean
Dim AccPacCon As New ADODB.Connection
Dim InvoiceSQL As New ADODB.Recordset
AccPacCon.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=ReadOnly;Password=readonly;Initial Catalog=TSTCOM;Data Source=SQL1"
InvoiceSQL.Open "SELECT COUNT(*) AS RECCOUNT FROM dbo.ARIBHO Where OPTFIELD = 'ZRBR' And VALUE = '" & ZRBRValue & "'", AccPacCon, adOpenForwardOnly, adLockOptimistic
If InvoiceSQL.Fields("RECCOUNT").Value > 0 Then
CheckUploaded = True
Else
CheckUploaded = False
End If
End Function
//////////////
This works but can I do the same query so that I use the active AccPac session, instead of creating an adodb connection?
///////////////
Function CheckUploaded(ZRBRValue As String) As Boolean
Dim AccPacCon As New ADODB.Connection
Dim InvoiceSQL As New ADODB.Recordset
AccPacCon.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=ReadOnly;Password=readonly;Initial Catalog=TSTCOM;Data Source=SQL1"
InvoiceSQL.Open "SELECT COUNT(*) AS RECCOUNT FROM dbo.ARIBHO Where OPTFIELD = 'ZRBR' And VALUE = '" & ZRBRValue & "'", AccPacCon, adOpenForwardOnly, adLockOptimistic
If InvoiceSQL.Fields("RECCOUNT").Value > 0 Then
CheckUploaded = True
Else
CheckUploaded = False
End If
End Function
//////////////
This works but can I do the same query so that I use the active AccPac session, instead of creating an adodb connection?