|
-
Jun 10th, 2008, 02:33 PM
#1
Thread Starter
Fanatic Member
[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
-
Jun 10th, 2008, 02:40 PM
#2
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.
-
Jun 10th, 2008, 02:48 PM
#3
Thread Starter
Fanatic Member
Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure
 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
-
Jun 10th, 2008, 02:54 PM
#4
Thread Starter
Fanatic Member
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
-
Jun 10th, 2008, 03:13 PM
#5
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.
-
Jun 10th, 2008, 03:22 PM
#6
Thread Starter
Fanatic Member
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 !
-
Jun 10th, 2008, 03:31 PM
#7
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.
-
Jun 10th, 2008, 03:52 PM
#8
Thread Starter
Fanatic Member
Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure
 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
-
Jun 10th, 2008, 05:28 PM
#9
Re: [02/03] DataGrid with The clause COMPUTE Using a Stored Procedure
 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 
-
Jun 10th, 2008, 05:32 PM
#10
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.
-
Jun 10th, 2008, 05:47 PM
#11
Thread Starter
Fanatic Member
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
-
Jun 10th, 2008, 06:41 PM
#12
Thread Starter
Fanatic Member
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
-
Jun 11th, 2008, 03:03 PM
#13
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|