Dim comm As New ADODB.Command
comm.ActiveConnection = 联接
comm.CommandText = "存储过程名"
comm.CommandType = adCmdStoredProc
comm.Parameters.Append comm.CreateParameter("参数名", adDate, adParamInput, , 变量)
comm.Execute
comm.ActiveConnection = 联接
comm.CommandText = "存储过程名"
comm.CommandType = adCmdStoredProc
comm.Parameters.Append comm.CreateParameter("参数名", adDate, adParamInput, , 变量)
comm.Execute
Public Function FindId(ID1 As Single) As Boolean
Dim pra_user_id As New ADODB.Parameter
Dim pra_user_exist As New ADODB.Parameter
Dim cmd_IsIdExist As New ADODB.Command
pra_user_id.Direction = adParamInput
pra_user_id.Type = adSingle
pra_user_id.Size = 9
pra_user_id.Value = ID1
pra_user_exist.Direction = adParamOutput
pra_user_exist.Type = adBoolean
pra_user_exist.Size = 1
cmd_IsIdExist.ActiveConnection = adoCnConnect
cmd_IsIdExist.CommandType = adCmdStoredProc
cmd_IsIdExist.CommandText = "prc_Find_ID"
cmd_IsIdExist.Parameters.Append pra_user_id
cmd_IsIdExist.Parameters.Append pra_user_exist
cmd_IsIdExist.Execute
FindId = pra_user_exist.Value
End Function
DIM adocn as new adodb.connection
adocn.open "Server=sqlserver;Server=soft;UID=sa;PWD=;Database=CHILDREN;"
strSQL = "pdCQA '" & dtBegin & "','" & dtEnd & "'," & lngTypeID
Set rsRet = adoConn.Execute(strSQL)
dim a as single
dim b as boolean
a=val(text1.text)
b=FindId(a)
msgbox b
'a是id号作为传入参数b是该id是否存在,是返回参数
public g_CN as ADODB.ConnectionPublic Sub GetSumByTitle(ByVal pTitle As String, _
pSum as Currency)Dim lcmRev As Command
Dim strCon as stringOn Error GoTo GetRevErr If g_CN Is Nothing Then '初始化数据库连接字符串
strCon = "Provider=SQLOLEDB.1;Persist Security Info=false;UID=" & _
mstrLogin & ";PWD=" & mstrPassword & _
";Initial Catalog=" & mstrDB & ";Data Source=" & _
mstrServer
End If
'初始化数据库连接
'Create the connection object if it doesn't exist
If g_CN Is Nothing Then
Set g_CN = New ADODB.Connection
'set the connection properties
With g_CN
.ConnectionString = strCon
.CommandTimeout = 30
.ConnectionTimeout = 60
End With
End If
'Connect if not already connected
If g_CN.State = adStateClosed Then
'Connect to the database
g_CN.Open
End If
' Create the Command
Set lcmRev = New Command
With lcmRev
.CommandText = "titles_sum"
.CommandType = adCmdStoredProc
.ActiveConnection = g_CN
End With' Create and append the parameters, both input and output
lcmRev.Parameters.Append lcmRev.CreateParameter("@title", _
adVarchar, adParamInput, 40, pTitle)
lcmRev.Parameters.Append lcmRev.CreateParameter("@sum", _
adCurrency, adParamOutput, 4)' Execute the command
lcmRev.Execute , , adExecuteNoRecords' Read the output parameters
pSum = lcmRev.Parameters("@sum")' Deallocate
Set lcmRev = NothingExit Sub
GetRevErr:
' Raise an error and deallocate
Err.Raise vbObjectError + 807, "GetSumByTitle", Err.DescriptionEnd Sub