Last post Jun 03, 2010 03:50 PM by Ariena
Jun 03, 2010 01:28 PM|Ariena|LINK
I tried to get help on another forum (here) but to no avail.
I am trying to call a stored procedure on my Oracle 11g database:
(Note - I had previously attempted to use a SqlDataSource control for the data source, but I wasn't getting anywhere. Would that have been a better choice?)
This executes without error, but then my grid just says "No records to display." I can't figure out why, because the query is returning results. Any help would be much appreciated!
Thanks in advance!
Oracle Stored Procedures
Jun 03, 2010 02:28 PM|Ariena|LINK
Sorry for the weird code formatting above, not sure how that happened...
Anyways, I think I found the issue - when I tested my stored procedure it came back with "Invalid cursor." So maybe the problem isn't what I thought it was, although I'm equally clueless as to why I'm getting this error.
Jun 03, 2010 03:50 PM|Ariena|LINK
Solved my problem on my own - figured I'd post the solution in case anyone runs across similar issues later.
The "invalid cursor" error was because I declared the cursor in the procedure - removing that line fixed that.
Then, I got another error: "Connection must be open for this operation". I fixed that by changing the code in my vb file to:
Protected Sub RadGrid1_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
Dim sql As String = "search_proc"
Dim cmd As New OracleCommand(sql, conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("cur", OracleDbType.RefCursor, ParameterDirection.InputOutput)
' This is what works
Dim da As New OracleDataAdapter(cmd)
Dim ds As New DataSet()
Me.RadGrid1.DataSource = ds
' This was what I had previously - gives error
'dr = cmd.ExecuteReader()
'RadGrid1.DataSource = dr
Me.testlbl.Text += "<br /><b>Success!</b>"
Catch err As System.Exception
Me.testlbl.Text += "<br /><b>Error!</b><br /><div id='err'>" + err.ToString() + "</div>"
End Sub 'RadGrid1_NeedDataSource