Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Returning Ref_cursor to dataview

Posted on 2009-05-20
6
Medium Priority
?
589 Views
Last Modified: 2013-11-07
I am trying to get the data grid (MyDataGrid) to populate.  I run the page with no errors.  Just for grins, I sent an invalid Oracle command, and sure enough, I got an oracle error returned - So I know the code is passing through to the Oracle DB.

I can't get the datagrid to populate/draw though.  I've tested my Stored Procedure otherwise (via SQL/Plus and Excel VBA) and it works fine.

Can somebody help me understand why MyDataGrid isn't showing up on my aspx page?

<%@ Page Language="c#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="Oracle.DataAccess.Client" %>
<%@ import Namespace="System.Data.OleDb" %>
<%@ Assembly Name="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" %>
<script runat="server">
 
    protected void Page_Load(Object sender, EventArgs e)
    
    {
    
      OracleConnection con = new OracleConnection("data source=myDatabase;user id=MyuserID;password=myPass;");
    
      con.Open();
    
      OracleCommand cmd = new OracleCommand("Pkg_CPU_Reports.Report_CPU_Histogram",con);
    
      OracleParameter oparam = cmd.Parameters.Add("ResultCursor", OracleDbType.RefCursor);
    
      oparam.Direction = ParameterDirection.Output;
    
       cmd.CommandType = CommandType.StoredProcedure;
    
      OracleDataAdapter adapter = new OracleDataAdapter(cmd);
    
      DataSet myset = new DataSet("ResultCursor");
    
      adapter.Fill(myset);
	  
	  DataGrid MyDataGrid = new DataGrid();
    
      MyDataGrid.DataSource=myset;
    
       MyDataGrid.DataBind();	
 
    }
</script>
<html>
 
 
 
<body>
 
<H1>Result Set</H1>
 
<form runat="server">
 
<asp:datagrid id="MyDataGrid" runat="Server"/>
 
</form>
 
</body>
 
</html>

Open in new window

0
Comment
Question by:tscottt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24441290
How many DataTable and rows does the DataSet have?
0
 
LVL 1

Author Comment

by:tscottt
ID: 24442762
About 10.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24446378
You didn't define any columns for the DataGrid.  If you are using ASP.NET 2.0, then I would suggest using the GridView, which can auto-generate columns from the data source.
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 1

Author Comment

by:tscottt
ID: 24446981
You're a champ for helping me!  I changed it to a GridView, but it still doesn't show a control (much less populate it with data).

As an experiment I changed : asp:GridView id="MyDataGrid"

to

asp: GridView id="nothing really"

And it behaved the same.  It's as if the MyDataGrid binding in the C## inline script isn't being recognized by the ASP:GridView.

 I also tried explicitly setting DataSourceID="myset" (the variable from the script) and DataSourceID="MyDataGrid", and neither of those worked.  At least they threw errors, though.

I'm probably missing something simple about how to bind my asp control to the control of the same name in the script.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24450411
Set the GridView's AutoGenerateColumns property to True.  DataSourceID is used with an SqlDataSource, ObjectDataSource, XmlDataSource, etc.
0
 
LVL 1

Accepted Solution

by:
tscottt earned 0 total points
ID: 24456557
I found the problem.  I was declaring the datagrid (or, in more recent code, the dataview) in the inline C# script - Line 30 in the code above. That's a no-no, as it goes out of scope.

Thanks for keeping me plugging away. :)
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question