现有一数据库A;其表为st_rnfl_r0 表的结构及记录如下:
STCDT YMDHM DTRN
xh03 2004-12-01 00:00:00.000 2.0
xh04 2004-12-02 00:00:00.000 3.0
xh02 2004-12-02 00:00:00.000 0.1
xh01 2004-12-03 00:00:00.000 8.1
xh03 2004-12-02 00:00:00.000 5.0
xh03 2004-12-03 00:00:00.000 0.0
xh04 2004-12-03 00:00:00.000 6.0
xh03 2005-02-21 00:00:00.000 1.0
xh03 2005-02-20 00:00:00.000 7.9
xh03 2005-02-19 00:00:00.000 0.5 我在数据库A中创建了存储过程 M_dtrn
CREATE PROCEDURE M_dtrn @nyear int,@name char(4) AS
select ymdhm,dtrn from st_rnfl_r0
where dtrn=(select max(dtrn) from st_rnfl_r0 where stcdt=@name and year(ymdhm)=@nyear )我希望在VB的Form窗体中调用存储过程 M_dtrn,并给其传递参数
通过变量将xh03和2005两个参数传递给参数,使@name=“xh03”,@nyear=“2005”,
然后得到两个查询结果值(t1,t2).
SQL查询后得出的结果为:
YMDHM DTRN
2005-02-20 00:00:00.000 7.9
在VB中我希望得到的结果是:
t1=2005-02-20 00:00:00.000
t2=7.9请诸位大侠帮忙看看,谢谢了.
STCDT YMDHM DTRN
xh03 2004-12-01 00:00:00.000 2.0
xh04 2004-12-02 00:00:00.000 3.0
xh02 2004-12-02 00:00:00.000 0.1
xh01 2004-12-03 00:00:00.000 8.1
xh03 2004-12-02 00:00:00.000 5.0
xh03 2004-12-03 00:00:00.000 0.0
xh04 2004-12-03 00:00:00.000 6.0
xh03 2005-02-21 00:00:00.000 1.0
xh03 2005-02-20 00:00:00.000 7.9
xh03 2005-02-19 00:00:00.000 0.5 我在数据库A中创建了存储过程 M_dtrn
CREATE PROCEDURE M_dtrn @nyear int,@name char(4) AS
select ymdhm,dtrn from st_rnfl_r0
where dtrn=(select max(dtrn) from st_rnfl_r0 where stcdt=@name and year(ymdhm)=@nyear )我希望在VB的Form窗体中调用存储过程 M_dtrn,并给其传递参数
通过变量将xh03和2005两个参数传递给参数,使@name=“xh03”,@nyear=“2005”,
然后得到两个查询结果值(t1,t2).
SQL查询后得出的结果为:
YMDHM DTRN
2005-02-20 00:00:00.000 7.9
在VB中我希望得到的结果是:
t1=2005-02-20 00:00:00.000
t2=7.9请诸位大侠帮忙看看,谢谢了.
我在执行语句set rst=cnn.execute("m_dtrn( 'xh03',2005)")已经成功,可我换成
set rst=cnn.execute("m_dtrn( X,Y)")时,系统提示错误.我该如何做,请各位高手给指点一下,谢谢!
with m_cmd
.ActiveConnection = MyApp.cn
.CommandType = adCmdStoredProc
.CommandText = "sp_tbl_OSD_Update"
.Parameters.Append .CreateParameter("@nyear", adBigInt, , , Y)
.Parameters.Append .CreateParameter("@name", advarchar, ,4, X)
.Execute
end with
Set comm = New ADODB.Command
conn.Open "Provider=SQLOLEDB.1;Password=密码;Persist Security Info=True;" & _
"User ID=用户名;Initial Catalog=数据库名;Data Source=计算机名"
Set comm.ActiveConnection = conn
With comm
.CommandTimeout = 15
.CommandType = adCmdStoredProc
.CommandText = "M_dtrn"
.Parameters.Append .CreateParameter("@nyear", adVarChar, _
adParamInput, 10, 2005)
.Parameters.Append .CreateParameter("@name", adVarChar, _
adParamInput, 4, 'xh05')
.Execute
End With
怎么接收返回值
比如存储过程里这样写:
raiserror('aaa error',16,1)
return -1怎么能抓到('aaa error',16,1)和-1?