第一次做前台,求救!拜托了!

xiewenlin2004 2005-10-19 12:17:46
我的Oracle程序如下:
type p_cursor is ref cursor;'自定义光标
Create or Replace Pocedure test( target_ID in varchar2,target_date in date,
result_Cursor out p_cursor
)
as
begin
open result_Cursor for
/*查询结果集*/
end test;
VB程序如下
private function test() as ADODB.Recordset
dim cnn as ADODB.connection
dim com as ADODB.command
Dim rs as ADODB.recordset

if cnn.open=adstateopen then cnn.close
end if;'如果数据源打开则关闭
with cnn'建立连接
.connectionstrin="..."
.open
end with
with com '初始化参数
.refresh
.ActiveConnection=cnn
.CommandType=AdStorePro
.CommandText="test.test(?)"
.parameter(0)="s345fvfve345"'为第一个变量赋值
.parameter(1)=cdate("2001-7-7")
end with
set rs=com.execute'执行并返回数据集合
test = rs'为函数赋值
end function
各位大哥我想请问的是我的这个程序怎么就运行不起来呢
...全文
85 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
faysky2 2005-10-19
  • 打赏
  • 举报
回复
运行不起来,是什么地方出错?
单步调试看是哪句出错(按F8)
winehero 2005-10-19
  • 打赏
  • 举报
回复
你这代码问题非常多,如ADO对象没初始化,由于是局部对象在此没必要判断Conn的State等等。。。单步调试或参照一下ADO Help提供的例子:
Public Sub OpenX()

Dim cnn1 As ADODB.Connection
Dim rstEmployees As ADODB.Recordset
Dim strCnn As String
Dim varDate As Variant

' Open connection.
strCnn = "Provider=sqloledb;" & _
"Data Source=srv;Initial Catalog=pubs;User Id=sa;Password=; "
Set cnn1 = New ADODB.Connection
cnn1.Open strCnn

' Open employee table.
Set rstEmployees = New ADODB.Recordset
rstEmployees.CursorType = adOpenKeyset
rstEmployees.LockType = adLockOptimistic
rstEmployees.Open "employee", cnn1, , , adCmdTable

' Assign the first employee record's hire date
' to a variable, then change the hire date.
varDate = rstEmployees!hire_date
Debug.Print "Original data"
Debug.Print " Name - Hire Date"
Debug.Print " " & rstEmployees!fName & " " & _
rstEmployees!lName & " - " & rstEmployees!hire_date
rstEmployees!hire_date = #1/1/1900#
rstEmployees.Update
Debug.Print "Changed data"
Debug.Print " Name - Hire Date"
Debug.Print " " & rstEmployees!fName & " " & _
rstEmployees!lName & " - " & rstEmployees!hire_date

' Requery Recordset and reset the hire date.
rstEmployees.Requery
rstEmployees!hire_date = varDate
rstEmployees.Update
Debug.Print "Data after reset"
Debug.Print " Name - Hire Date"
Debug.Print " " & rstEmployees!fName & " " & _
rstEmployees!lName & " - " & rstEmployees!hire_date

rstEmployees.Close
cnn1.Close

End Sub
qgxa 2005-10-19
  • 打赏
  • 举报
回复
我的Oracle程序如下:
type p_cursor is ref cursor;'自定义光标
Create or Replace Pocedure test( target_ID in varchar2,target_date in date,
result_Cursor out p_cursor
)
as
begin
open result_Cursor for
/*查询结果集*/
end test;
VB程序如下
private function test() as ADODB.Recordset
dim cnn as new ADODB.connection'加个new
dim com as ADODB.command
Dim rs as ADODB.recordset

if cnn.open=adstateopen then cnn.close
end if;'如果数据源打开则关闭
with cnn'建立连接
.connectionstrin="..."
.open
end with
with com '初始化参数
.refresh
set .ActiveConnection=cnn'加个set
.CommandType= adCmdStoredProc'换成这样
.CommandText="test"'换上你的存储过程的名字就可以了不用带参数
.parameter(0)="s345fvfve345"'为第一个变量赋值
.parameter(1)=cdate("2001-7-7")
end with
set rs=com.execute'执行并返回数据集合
test = rs'为函数赋值'你这个test一定也要是一个记录集才行
end function
现在你可以试运行一下了
上官云峰 2005-10-19
  • 打赏
  • 举报
回复
设置断点,查看那个地方出错,然后解决,否则不知道那里错了,一步一步找,不是很浪费时间
还有
set rs=com.execute 这里要写成这样把set rs=com.execute(sql) sql是你的sql语句把
test = rs
end function

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧