[b]Fill a DataGrid with the returned data of a Stored Procedure[/b]

Hi
I'm trying to use a stored procedure that returns data from the table tab_proc1 and a DataGrid that will display the results.
Any help would be appreciated.
bebop
created the following in MS SQL Server:
a table:
create table tab_proc1 (col1 char(10), col2 char(10))
a stored procedure:
create procedure sp_test1
as
select * from tab_proc1
Code I'm using:
using System.Data;
using System.Data.SqlClient;
namespace spapc
     /// <summary>
     /// Summary description for WebForm1.
     /// </summary>
     public class WebForm1 : System.Web.UI.Page
          protected System.Web.UI.WebControls.DataGrid DataGrid1;
          protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
          protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
          protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
          protected System.Data.SqlClient.SqlConnection sqlConnection1;
          protected sptempdbTEST.DataSet1 dataSet11;
          protected System.Web.UI.WebControls.Button Button1;
          private void Page_Load(object sender, System.EventArgs e)
     //sqlDataAdapter1.Fill(dataSet11);
          //Page.DataBind();
private void Button1_Click(object sender, System.EventArgs e)
SqlConnection conn = new SqlConnection("server=localhost;database=apc;uid=ty;pwd=");
try
     conn.Open();
     SqlCommand cmd = new SqlCommand("sp_test1", conn);
     cmd.CommandType = CommandType.StoredProcedure;
     //cmd.CommandText = "sp_test1";
     SqlDataAdapter myadapter =new SqlDataAdapter();
     myadapter.SelectCommand = cmd;
     myadapter.Fill(dataSet11);
     //DataGrid1.DataSource=dataSet11.Tables("tab_proc1");
     DataGrid1.DataSource = cmd.ExecuteReader();
     DataGrid1.DataBind();
catch (SqlException ex)
     finally
     conn.Close();

Why are you posting to an Oracle site when you are using MS SQL Server? This is a discussion forum for ODP.NET which stand for ORACLE Data Provider for .NET. Not MS SQL Data Provider for .NET!!

Similar Messages

  • How to view the returned data from a stored procedure in TOAD?

    Hi,
    I created ref cursor in the stored procedure to return data. The stored procedure works fine, just want to view the result in TOAD. The BEGIN... EXEC... END can execute the stored procedure, but how to make the result display?
    Thanks!

    Right click the editor and choose
    "Prompt For Substitution Variables".
    Run for example the following code:
    DECLARE
    PROCEDURE p (cur OUT sys_refcursor)
    AS
    BEGIN
    OPEN cur FOR
    SELECT *
    FROM DUAL;
    END p;
    BEGIN
    p (:cur);
    END;
    The result will display in Toad's Data Grid!
    Regards Michael

  • How to view the returned data from a stored procedure?

    Hi,
    I created ref cursor in the stored procedure to return data. But how can I view the data when I execute it? The stored procedure works fine, just want to view the result.
    Thanks!

    SQL>set serveroutput on size 100000;
    SQL>set autoprint on
    SQL>variable cv refcursor;
    SQL>exec proc_name(param1,:cv);

  • Filling a range with the same date in Numbers '09

    I know if you type a date in to a field and then drag the corner it will fill successive dates, but is there a way to fill a range of cells with the same date so I don't need to retype them each time?

    Create a pattern of what you want, then do "fill"
    Enter the same date in two or three cells, in a row or column, then drag to fill the range. Numbers should recognize the pattern you created and continue it.

  • The ways to return data from a stored procedure.

    Hi, I know there are three ways to pass out a value from a Microsoft SQL stored procedure, but I have no clear idea what Oracle SP can do, I know Oracle doesn't support multi-recordset(v8), can not return a recordset by a inner select query, but I do know there is a cursor object, which doesn't like its counterpart in Microsoft SQL server, is a choice under most situation. Here I wonder anyone who is good at Oracle can give a list of all ways to return data from a SP, including example is more better, thanks.

    Here is a way to get return a record from a function and a procedure. You need to be familiar with Oracle packages as well as stored procedures and functions:
    CREATE OR REPLACE PACKAGE EmpPkg AS
    cursor cEmp(pEmpno in number) is
    select empno, ename, job, hiredate, sal
    from emp
    where empno = pEmpno;
    FUNCTION GetEmployee(pnEmpNo in number) RETURN cEmp%rowtype;
    PROCEDURE GetEmployee(pnEmpNo in number, prEmp out cEmp%rowtype);
    END;
    CREATE OR REPLACE PACKAGE BODY EmpPkg AS
    FUNCTION GetEmployee(pnEmpNo in number) RETURN cEmp%rowtype IS
    rEmp cEmp%rowtype;
    BEGIN
    open cEmp(pnEmpNo);
    fetch cEmp into rEmp;
    close cEmp;
    return rEmp;
    END;
    PROCEDURE GetEmployee(pnEmpNo in number, prEmp out cEmp%rowtype) IS
    BEGIN
    open cEmp(pnEmpNo);
    fetch cEmp into prEmp;
    close cEmp;
    END;
    END;
    Here's how you use the package:
    DECLARE
    rEmp EmpPkg.cEmp%rowtype;
    BEGIN
    rEmp := EmpPkg.GetEmployee(7782);
    dbms_output.put_line(rEmp.ename);
    EmpPkg.GetEmployee(7902, rEmp);
    dbms_output.put_line(rEmp.ename);
    END;
    Note that you can return any Oracle data type from a function. Likewise, you can specify any Oracle data type as an out parameter in a procedure. Also, you can make a parameter both an in and an out datatype like this:
    PROCEDURE GetEmployee(pnEmpNo in out number);
    I hope this puts you in the right direction.
    null

  • Use return date value in stored procedure

    hi
    i am new in oracle , i make stored procedure to fetch data in the form and i make calendar , i want user when they select a date from date LOV the stored procedure use this date in the query.. i try like this in the query:
    when time=:blok.date_item;
    but i get IN OUT error in the procedure.
    any help will be appreciated.

    ok this is the package header:
    create or replace package get_outvalue_test is
    type rec is record (time archive.time%type,
    value archive%type);
    type value_tab is table of rec index by binary_integer;
    procedure get_value(p_returnvalue IN OUT value_tab);
    end;
    package body :
    create or replace package body get_outvalue_test is
    procedure get_value(p_returnvalue IN OUT value_tab)
    is
    ii number;
    cursor valselect is
    select time,value from archive where u_id=5666
    and time=:block.date_item ; -- this is the return date from LOV
    begin
    open valselect;
    ii:=1
    loop
    fetch valselect into
    p_returnvalue(ii).time;
    p_returnvalue(ii).value;
    exite when valselect %notfound;
    ii:=ii+1;
    end loop;
    end;
    end;
    this is the error when i compile the package body :
    MIssing IN or OUT parameter at index
    i hope itis cleare and easy .

  • How do I get the returned cursor from a stored procedure to an asp.

    Sorry if this topic has been answered before but I am new to Oracle and ASP. I have been asked to create some stored procedures and access the results from the ASP. I will be passing one variable in and could be getting upto 200 rows returned.
    I have no trouble with the stored procedure but have no clue how to retrieve the data returned by it.

    Assuming that the stored procedure has a single argument, an OUT cursor, you should be able to do
    SQLExecDirect
    {call <stored_proc>() }
    SQLFetch
    SQLGetData
    We'll handle all the 'magic' underneath.
    Justin Cave
    ODBC Development

  • What's with the semicolon 1 notation in stored procedures?

    when I have a stored procedure as a data source, what is the meaning of ";1" that crystal appends to the name?

    had the same error in MS Access. Updating to the latest service pack did the trick.
    The point is, that you can have different versions of SPROCS in MS SQL Server (they could have the same name but completely different code). They get named like [SPROCNAME];[#]
    So I guess, its a bug in Crystal Reports that puts the version number of the SPROC after its name.
    check this out:
    CREATE PROCEDURE [dbo].[spTest]
    AS BEGIN SELECT @@MICROSOFTVERSION END
    GO
    CREATE PROCEDURE [dbo].[spTest];2 AS SELECT @@version
    GO
    EXEC spTest;1 EXEC spTest;2
    credit: [klick!|http://stackoverflow.com/questions/1287787/weird-error-using-sql-server2005-sprocs-from-ms-access-2000-1-in-name-not]

  • In sm30, when save, how to fill the table with the system data in the table

    Hi all, in SM30, we have user name and time fields, when we create record, after we click the SAVE button, it will automatically fill the fields with the system data, how can we realize it?

    Hi ,
    Do like this.
    1. Go to SE11 -> give your table name and press on change button .
    2.Go to Menu->Utilities-> Table Maintainance Generator , then it will take you another screen .
    3.Assign Functin group if already have one , other wise create function group and assign
    4.Go to Menu->Environment->Modification->Events , again it will take you to another screen
    5.Click on new entries
    ->Now press F4 in T column . Select<u> "01" - Before saving the data in the database</u> and in form routinue give any name of the routinue like "SAVE_USER_DATA" and press enter then u can see an editor symbol in next column click on that it will take you ABAP editor there type this code .
    ztable-username = sy-uname.
    ztable-createtime = sy-uziet.
    check and activate the code .
    With this your job will be complete . Now while entering data just leave columns blank , they will insert corresponding username and time
    Don't forget award points if it helps you.
    Regards,
    Raghav

  • Table is not filling with the RFC data

    Hi,
       I am new to WDJ. I have a created a wdj application by importing adaptive RFC model. deployment is sucessful but at runtime the table is not getting filled up with the RFC data. RFC is executing find from the backend. JCO is maintained correctly in the webdynpro, mapping and  binding is done.
    Could someone guide where could be the problem?
    I am giving the code below for doinit and service controller method.
    public void wdDoInit()
        //@@begin wdDoInit()
        //$$begin Service Controller(-222509821)
        wdContext.nodeZsalesheader_Data_Input().bind(new Zsalesheader_Data_Input());
    //     wdComponentAPI.getMessageManager().reportSuccess("Node value " + wdContext.currentContextElement().getAttributeAsText("auart"));
        //$$end
        //@@end
    public void executeZsalesheader_Data_Input( )
        //@@begin executeZsalesheader_Data_Input()
        //$$begin Service Controller(-1232218854)
        IWDMessageManager manager = wdComponentAPI.getMessageManager();
        try
         wdContext.nodeOutput().invalidate();
          wdContext.currentZsalesheader_Data_InputElement().modelObject().execute();
        catch(WDDynamicRFCExecuteException e)
          manager.reportException(e.getMessage(), false);
        //$$end
        //@@end
    Can anybody guide if am missing something?
    Regards
    Sireesha.

    Anup and all,
    Can anyone please identify whats the mistake in the below code?
    OnLeadSelect Event
        wdContext.nodeZsalesheader_Data_Input().getElementAt(wdContext.getLeadSelection()).getAttributeValue("Vbeln"));
    I am getting a runtime exception that "unknown attribute Vbeln".
    Here is my Context Node.
    ---Zsalesheader_Data_Input
    Output
    T_Salesheader
    Vbeln
    Auart
    Vbtyp
    Trvog
    As per the above Context structure is my code correct? If not how do i read the value vbeln from the above context?
    Can anyone pls advice?
    Regards
    Sireesha.

  • Filling a tree with the result of calls to a document/wrapped soap1.1 webservice

    Hi,
    I'm having trouble with filling a tree with the result to
    calls to a document/wrapped soap 1.1 webservice.
    I first declared the webservice in the mxml file as it was in
    the examples and tried to call it with no luck. The fault was it
    wasn't finding the document type for the call's unique parameter. I
    figured out the solution to this, I added a method in the
    webservice declaration having a single element named the same as
    the required parameter, and inside it, the "actual" parameters,
    bound to variables defined elsewhere.
    The reason for wanting the tree to be filled programatically,
    is the potential whole contents of the tree can be about 1.000.000
    nodes. Huge.
    quote:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" applicationComplete="initM()">
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    import mx.controls.Alert;
    import mx.controls.treeClasses.TreeListData;
    [Bindable] public var aParentId:String = null;
    [Bindable] public var aLevel:Number = 0;
    ]]>
    </mx:Script>
    <mx:WebService id="lws" wsdl="
    http://myServer/myContext/myPortURI?WSDL"
    useProxy="false" makeObjectsBindable="true">
    <mx:operation name="getNodes" resultFormat="object">
    <mx:request>
    <getNodesElement>
    <parentId>{aParentId}</parentId>
    <level>{aLevel}</level>
    </getNodesElement>
    </mx:request>
    </mx:operation>
    </mx:WebService>
    <mx:Tree x="0" y="0" width="326" height="100%"
    id="layoutTree" enabled="true" labelField="nodeName">
    <mx:dataProvider>{lws.getNodes.lastResult}</mx:dataProvider>
    </mx:Tree>
    <mx:Script>
    <![CDATA[
    public function initM():void {
    lws.getNodes.send();
    return;
    ]]>
    </mx:Script>
    </mx:Application>
    So, here's the problem:
    1.- In both Java2 and .NET, I've been able to produce sets of
    proxy classes from the webservice wsdl, these include a proxy class
    for the service port and a set of classes for both the call
    parameter types and the call result types. I have not found yet a
    way to do the same with flex2, so I wonder, can I produce the
    required classes for dealing with such a webservice in an automatic
    way with flex2?
    2.- The second problem, is I haven't found a way to make a
    webservice call in sychronous mode, and I can't seem to find a way
    to set the parameters for the subsequent calls to the webservice.
    Is there a way to make a call to such webservice programatically? I
    mean, I've been able to make the first call I need programatically,
    but what if I end up making 2 or more simultaneous calls? I can't
    rely on setting the `variables defined elsewhere` before each call,
    because of possible concurrency issues (calls will be long after
    the 2nd level of the tree), so I wonder if there's a way to make a
    call to such webservice (document/wrapped, soap1.1) passing it the
    parameters programatically. If so, can I just put the parameters or
    do I have to produce the complete enclosure? If I have to produce
    also the enclosure, any hint on how to do so? I will need to pass
    different parentId, level pairs probably triggered by tree events.
    3.- the other problem, finally, is Tree looks quite different
    to me than the Java2 one. In java2, I can easily produce a changing
    model for the tree wich will even handle the calls to the
    webservice as needed (triggered by the tree itself), making it a
    `live model`. If there is a way to produce the same behaviour in
    flex2, I haven't found it yet. Sure, I've only downloaded the trial
    version yesterday, so I may have overlooked some docs or blogs.
    Any hints would be appreciated, specially on programatically
    modifying the tree, and making calls to the webservice changing the
    parameters every time.

    I would re-post to the Flex Data Services forum.

  • [Help Wanted] soap1.1 webservice, filling a tree with the result of calls...

    Hi,
    I'm having trouble with filling a tree with the result to
    calls to a document/wrapped soap 1.1 webservice.
    I first declared the webservice in the mxml file as it was in
    the examples and tried to call it with no luck. The fault was it
    wasn't finding the document type for the call's unique parameter. I
    figured out the solution to this, I added a method in the
    webservice declaration having a single element named the same as
    the required parameter, and inside it, the "actual" parameters,
    bound to variables defined elsewhere.
    The reason for wanting the tree to be filled programatically,
    is the potential whole contents of the tree can be about 1.000.000
    nodes. Huge.
    quote:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" applicationComplete="initM()">
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    import mx.controls.Alert;
    import mx.controls.treeClasses.TreeListData;
    [Bindable] public var aParentId:String = null;
    [Bindable] public var aLevel:Number = 0;
    ]]>
    </mx:Script>
    <mx:WebService id="lws" wsdl="
    http://myServer/myContext/myPortURI?WSDL"
    useProxy="false" makeObjectsBindable="true">
    <mx:operation name="getNodes" resultFormat="object">
    <mx:request>
    <getNodesElement>
    <parentId>{aParentId}</parentId>
    <level>{aLevel}</level>
    </getNodesElement>
    </mx:request>
    </mx:operation>
    </mx:WebService>
    <mx:Tree x="0" y="0" width="326" height="100%"
    id="layoutTree" enabled="true" labelField="nodeName">
    <mx:dataProvider>{lws.getNodes.lastResult}</mx:dataProvider>
    </mx:Tree>
    <mx:Script>
    <![CDATA[
    public function initM():void {
    lws.getNodes.send();
    return;
    ]]>
    </mx:Script>
    </mx:Application>
    So, here's the problem:
    1.- In both Java2 and .NET, I've been able to produce sets of
    proxy classes from the webservice wsdl, these include a proxy class
    for the service port and a set of classes for both the call
    parameter types and the call result types. I have not found yet a
    way to do the same with flex2, so I wonder, can I produce the
    required classes for dealing with such a webservice in an automatic
    way with flex2?
    2.- The second problem, is I haven't found a way to make a
    webservice call in sychronous mode, and I can't seem to find a way
    to set the parameters for the subsequent calls to the webservice.
    Is there a way to make a call to such webservice programatically? I
    mean, I've been able to make the first call I need programatically,
    but what if I end up making 2 or more simultaneous calls? I can't
    rely on setting the `variables defined elsewhere` before each call,
    because of possible concurrency issues (calls will be long after
    the 2nd level of the tree), so I wonder if there's a way to make a
    call to such webservice (document/wrapped, soap1.1) passing it the
    parameters programatically. If so, can I just put the parameters or
    do I have to produce the complete enclosure? If I have to produce
    also the enclosure, any hint on how to do so? I will need to pass
    different parentId, level pairs probably triggered by tree events.
    3.- the other problem, finally, is Tree looks quite different
    to me than the Java2 one. In java2, I can easily produce a changing
    model for the tree wich will even handle the calls to the
    webservice as needed (triggered by the tree itself), making it a
    `live model`. If there is a way to produce the same behaviour in
    flex2, I haven't found it yet. Sure, I've only downloaded the trial
    version yesterday, so I may have overlooked some docs or blogs.
    Any hints would be appreciated, specially on programatically
    modifying the tree, and making calls to the webservice changing the
    parameters every time.

    1. Not yet, but we're looking into supporting this in an
    upcomming release.
    2. All RPC requests must be made asynchronously... this is a
    restriction of the way the Flash Player makes network requests
    (otherwise movies, which are single threaded, would hang waiting
    for results). You should be able to use the ActionScript API to
    programmatically call web services with normal parameters.
    3. If you leave makeObjectsBindable="true" (which it is by
    default) the Objects and Arrays will be wrapped in ObjectProxies
    and ArrayCollections automatically and will report change events,
    however I don't believe that we have an example that links these
    change events up to subsequent web service calls, but it would be
    possible (but not automatic). A feature that does do this sort of
    thing automatically is the Data Service, although this does not use
    WSDL/SOAP to describe/communicate with remote services and you have
    to setup a Java assembler to work with our adapters on the
    server.

  • Can I populate a text field in one PDF with the modification date of a different file ?

    Rather convoluted problem here but I'm trying to place a text field on a PDF document that serves as the main menu page for a library of interlinked PDF documents
    The complete library contains over 7,000 files and additions are added and documents changed almost daily.
    We currently use batch files to open the main menu from it's shortcut and this runs a check on a sync log file (.txt) to ascertain when the last time the user synchronised with the server to get the latest copy of the files.
    Between a certain time range they are told how long it has been since they sync'ed and are offered the option to sync before opening, after a prescribed timeframe they cannot enter without synchronising. We use Allways Sync to conduct the file synchronisation with our mother files on our server.
    What I'd like to do is take advantage of Allways Syncs automatic synchronisation options to synchronise on log on and at prescribed idle periods there after.
    This works fine but I'd like the text field on the main menu PDF to say when the last synchronisation took place - easy if the main menu is the last file modified .. just use info.modDate.
    However, the main menu is rarely modified therefore I wish to import the text to populate the text field from a different file.. either by interrogating the other files modifictaion data (though I doubt Acrobat can do this) or by simply importing some text stored in another file (a .txt file?) which has previously been created by batch file commands.
    Any assistance would be greatly appreciated.
    Regards,
    Nifty Styles
    (Norfolk, England)
    P.S.  I'm using Acrobat 8.3.1. Professional on Windows XP (SP3).

    Thank you for all your help above.
    Just to confirm your advice, am I right with the following conclusions? :
    1. The script (function) to fill the text field with the modification date of a different PDF file needs to be stored in a folder level .js file.
    2. The document containing the text field needs to call the .js function either within the document script or within the custom script property of the text field itself.
    Further to that can you just advise on the syntax for accessing the modification date of the other document.
    Do I need to assign a variable to the address of the file to be used, and then use this variable in the text form filling script (as below) or can I use a direct file reference at the .modDate command.
    var LastSync = "C:\sync\bin\lastsync.pdf";
    var strMsg = util.printd("h:MM tt",LastSync.modDate) + " on ";
    strMsg += util.printd("dddd, d mmmm, yyyy",LastSync.modDate);
    this.getField("LastSyncDate").value = strMsg;
    If the syntax is totally different to the above I would be very grateful for some guidance in the right direction.
    I much appreciate your time to help me ... I'm almost there.
    Kind Regards,
    Nifty

  • Create a node with the newest date only

    Hi, I want to create a node in the target, only by the newest date from the source. The source is an Idoc with, say, 3 segments of the same kind, with different dates. Only the segment with the newest date, should be created in the target.
    Any Ideas?

    Hi,
    it's easy but with user defined functions:
    - put all segments into the UDF
    - then inside this UDF choose the one with the
    latest date and put it into the array (global variable)
    - then take the values from the global variable
    to fill the sements (from new UDFs)
    you could also try with
    DateBefore and DateAfter functions
    and try to do it without UDFs
    with logic like
    if date1 DateBefore date2 then ....
    Regards,
    michal

  • Can I return my MacBook Air past the return date?

    Hi, I have a question that I've been googling but I haven't been able to find an answer to anywhere. Can I return a MacBook Air past the return date to an Apple store if it is still in shrink-wrap and I have a receipt? Thanks.

    I would think you cannot return a product after the return date has passed.
    Call the Apple Store and ask them.

Maybe you are looking for

  • Is it possible to create a view where table in the From clause changes name

    is it possible to create a view from a from a table like this create view my_view as select id, col1, col2, result from <<my_latest_cacahe_table>>; the table in the from clause changes the name . I have another table which indicates the the latest na

  • Pricing simulation

    hello, friends. need your help...  i understand that there is no standard transaction in SD to simulate pricing (other than using a dummy sales order).  however, we have pricing reports using V/LD so that we could list condition types based on access

  • Issue in content conversion .fieldSeparator

    Hello !! I am trying to post a file with * delimiter and for that I am using the below content conversion : record.fieldNames - f1,f2,f3,f4,f5 record.fieldSeparator - all the fields under record are optional. When the sending system is sending the da

  • Hiding Customized fields through Config - T88M

    Hi, My system parameter is : ECC 6.0. As per requirement in my project, I have customized IT7 and added a new field - Annual Time . I am populating that field by default using some logic which wrote in the PBO of the newly created module pool and eve

  • E72 Power Saving Mode

    Hi All, My Nokia E72 is constantly saving that its in power saving mode. Is there a way to get it out of the power saving mode? I searched everywhere in the phone and in the disccussion board. Thanks.