Results 1 to 13 of 13

Thread: [RESOLVED] [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Resolved [RESOLVED] [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    Hello ,

    i have a stored procedure which i use in the clause Compute (Total Money) for each one
    i want to attach this Stored Procedure to a DataGrid
    but i got a message that Instruction COMPUTE BY dont work or nOt supported

    Thanks

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    The Compute() method takes an 'expression' and a 'filter'. It will not work with stored procedures.

    http://msdn.microsoft.com/en-us/libr...e.compute.aspx

    If you want to call a stored procedure, it must be done when doing the initial database call to bind the grid.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    Quote Originally Posted by mendhak

    If you want to call a stored procedure, it must be done when doing the initial database call to bind the grid.
    hi menhak ,

    Plz can you give more infos , How to ?
    i have it working using SQL Server 2000 like the format want
    if you have any element to do that different than DataGrid
    it will be Great

    Thanks

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    I Just need any element to display this Stored Procedure like it is in SQL Server 2000

    Thanks

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    I do not understand what you want. Use more words and descriptions to talk about your problem.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    oK m8 ,

    i had a question to Show This Query like This using a Stored Procedure in Sql Server 2000

    N'Reg Date Reg Way Salary
    1 2007-12-12 00:00:00.000 C 250.0000
    1 2007-12-12 00:00:00.000 C 580.0000
    Sum
    830.0000
    N'Reg Date Reg Way Salary
    2 2007-12-15 00:00:00.000 E 360.0000
    Sum
    360.0000

    i made
    after order by NReg
    compute sum(Salary by NReg

    Now it Say that i should use This Stored Procedure in .Net
    i thought DataGrid will attached to this Stored procedure & show me the exact display
    but Not

    if you need more details , i will clarify more

    it doesnt matter what i use DataGrid or ListBox
    just i want to get the same dispaly that i got in SQL Server 2000


    Thanks m8 !

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    Code:
        SqlConnection conn = new SqlConnection("Data 
    Source=localhost;Database=Northwind;Integrated Security=SSPI");
        SqlCommand command = new SqlCommand("GetProducts", conn);
        SqlDataAdapter adapter = new SqlDataAdapter(command);
        DataSet ds = new DataSet();
        adapter.Fill(ds, "Products");
    Then you can set the datasource of the datagrid to be the dataset.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    Quote Originally Posted by mendhak
    Code:
        SqlConnection conn = new SqlConnection("Data 
    Source=localhost;Database=Northwind;Integrated Security=SSPI");
        SqlCommand command = new SqlCommand("GetProducts", conn);
        SqlDataAdapter adapter = new SqlDataAdapter(command);
        DataSet ds = new DataSet();
        adapter.Fill(ds, "Products");
    Then you can set the datasource of the datagrid to be the dataset.
    What do you mean by This ?
    i do not talk about a simple Stored Procedure
    but stored procedure that has a compute by inside

    Thanks

  9. #9
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    Quote Originally Posted by killer7k
    Now it Say that i should use This Stored Procedure in .Net
    i thought DataGrid will attached to this Stored procedure & show me the exact display
    but Not
    If i am not wrong you are seeing your query output in Text Mode (In query analyser) Just change it to Grid mode and u will noticed that its not just a single table but for every Group in your case it's NReg you will get different table,so when you call this stored procedure you get bunch of table so how you can expect grid (using dataset) to show Formatted output what you might be getting in SQL analyser
    __________________
    Rate the posts that helped you

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    It's hard to understand you.

    There's a SQL COMPUTE and there's a DataTable.Compute().

    Look at the link for information on COMPUTE.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    Sorry m8 ,
    but i have just a question for you
    let's say you have a stored procedure like this

    Create Procedure GetRes
    as
    SELECT SalesPersonID, CustomerID, OrderDate, SubTotal, TotalDue
    FROM Sales.SalesOrderHeader
    ORDER BY SalesPersonID, OrderDate
    COMPUTE SUM(SubTotal) BY SalesPersonID;



    working very well in Sql Server 2000

    & You want to use it with DataGrid

    here is the Code

    Code:
     cmd = con.CreateCommand
                cmd.CommandText = "GetRes"
                cmd.CommandType = CommandType.StoredProcedure
                da.SelectCommand = cmd
                da.Fill(ds, "GetRes")
                DataGrid1.DataSource = ds
                DataGrid1.DataMember = "GetRes"
    it Say Instruction COMPUTE BY NOT SUPPORTED


    I Just wanto you to test it & show me result

    Thanks

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    i got it working had problem in 2003
    Tested on 2005 working with DataGrid no DataGridView
    it show Tree to choose & then displayed

    Thanks

  13. #13
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure

    Glad to know it's working. It's better to switch to the 'latest' version if it's a choice for you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width