贴子见:http://dev.csdn.net/article/32/32331.shtm
delcare @jifen decimal(19,2)‘下面的类型需要注意,如果不使用adSingle,会发生一个精度无效的错误 Set param = cmd.CreateParameter("jifen", adSingle, adParamInput, 50, Val(txtjifen.Text)) cmd.Parameters.Append param Set rs1 = cmd.Execute
delcare @jifen decimal(19,2)‘下面的类型需要注意,如果不使用adSingle,会发生一个精度无效的错误 Set param = cmd.CreateParameter("jifen", adSingle, adParamInput, 50, Val(txtjifen.Text)) cmd.Parameters.Append param Set rs1 = cmd.Execute
Dim iCmd As ADODB.CommandSet iCmd = New ADODB.Command
With iCmd
.ActiveConnection = "数据库连接字符串"
.CommandType = adCmdStoredProc
.CommandText = "存储过程名"
.Parameters.Refresh '这句就是让自己分析存储过程,并创建参数列表
.Parameters("@输入参数")="参数的值" '为输入参数赋值
End With
End Sub
Dim iCmd As ADODB.CommandSet iCmd = New ADODB.Command
With iCmd
.ActiveConnection = "数据库连接字符串"
.CommandType = adCmdStoredProc
.CommandText = "存储过程名"
.Parameters.Refresh '这句就是让自己分析存储过程,并创建参数列表
.Parameters("@输出参数").Direction =adParamOutput '指定为输出参数
.Execute
End With
.Parameters("@输出参数").Direction =adParamOutput '指定为输出参数
create proc a
@a int out
as
set @a=1
go------------------------------------------------
'测试的VB过程
Sub cmd()
Dim iCmd As ADODB.Command
Dim iRe&Set iCmd = New ADODB.Command
With iCmd
.ActiveConnection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=test"
.CommandType = adCmdStoredProc
.CommandText = "a"
.Parameters.Refresh
.Execute
MsgBox .Parameters("@a")
End With
End Sub