ado| Data Option Explicit
public PUBCN as New ADODB. Connection
dim Temp_i as Integer
"" Connection Database
public Sub GetConnect ()
£
on Error GoTo ErrorHandler:
dim Constr as String
if not (PUBCN. State = 0) Then
PUBCN. Close
end If
£
PUBCN. CursorLocation = adUseClient
PUBCN. ConnectionTimeout = 5
PUBCN. Open "Provider=sqloledb;" & _
"Network Library=dbmssocn" & _ "indicates that the ip+ port is used to find SQL Server
"Data source=172.17.21.125,1433;" & _
"Initial Catalog=hpdata" & _
"User Id=user;" & _
"Password=password" & _
"Encrypt=yes"
£
PUBCN. DefaultDatabase = "Hpdata" '!!!!!!!!!!!!!!!!
exit Sub
errorhandler:
dim msg as Integer
msg = MsgBox ("Error on Connection:" & Err.Number & Err.Description & err.source & "Please send this message to the mailbox", vbOKOnly)
£
end Sub
£
"" Simple query to get dataset////////////////////////////////////////////////////////
public Function getrs (sqlstr as String) as ADODB. Recordset
£
on Error GoTo ErrorHandler
call GetConnect
£
set getrs = New ADODB. Recordset
£
getrs.open sqlstr, PUBCN, adOpenStatic, adLockOptimistic
£
set getrs.activeconnection = Nothing
£
PUBCN. Close
exit Function
errorhandler:
dim I as Integer
i = MsgBox (Sqlstr & "::::::" & Err.Description & Err.helpcontext, vbOKCancel)
£
end Function
' Sync data set
public Sub updaters (Rs as ADODB. Recordset, Optional Requerryflag as Integer)
call GetConnect
£
with Rs
. ActiveConnection = PUBCN
. Update
' If (not IsMissing (Requerryflag)) and Requerryflag = 1 Then ' changed to February 6, 2004 for repair except history record the modification of the customer number query cannot be synchronized with the data
. " Requery
£ ' End If
. ActiveConnection = Nothing
end with
£
PUBCN. Close
£
end Sub
' Execute query with parameter object to get DataSet
public Sub getrsfromcmd (Cmd as Adodb.command, str as String, Rs as ADODB. Recordset)
£
on Error GoTo ErrorHandler
call GetConnect
if not (cmd.state = adstateclosed) Then
cmd.cancel
cmd.activeconnection = Nothing
end If
with CMD
. ActiveConnection = PUBCN
. CommandTimeout = 5
. CommandType = adCmdText
. CommandText = str
end with
if not (rs.state = 0) Then
rs.close
end If
rs.open CMD, adOpenStatic, adLockOptimistic
£
rs.activeconnection = Nothing
£
with CMD
. ActiveConnection = Nothing
end with
PUBCN. Close
exit Sub
errorhandler:
temp_i = MsgBox (str & err.number & Err.Description & Err.Source, vbOKOnly)
£
end Sub
' Execute an SQL statement that returns no results
public Sub Cnexecute (ByVal qstr as String, ByRef recordnumber as Long, Optional QRs as ADODB. Recordset)
&n