Implementation of an off-line ADO data management module

Source: Internet
Author: User
Tags exit goto integer
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.