Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Dear All,
 
I have a situation in my C#.Net-Sql Program.
 
I want create a excel report for my new company, In the report number of columns based on some other master table condition,also master table entries should be the column headers.So pivoting of master table is needed(2 times).
So i panned things as follows ,
1)Create a stored procedure with parameters.
2)Execute the stored procedure from C# and read/store table formatted data in a C# DataTable.
3)Print the DataTable values to an Excel .
 
So i create a stored procedure ,when i am running it in sql server it is working fine and the a table structured output is coming as expected .
 
Now i tried to run it from C# , DataTable Fill results 0 rows and 0 columns.
 
Why this happened like this ???
 
I had a temporary solution, as
i altered the Procedure and tried to save the output to a dynamic table (Using select * into) . Then i check the dynamic table after the program execution ,i found the out put is saved in that dynamic table .
 
Then i read the data of this dynamic table using another procedure .
 
Thanks&Regards,
Aadyakumar.D.V
Posted 27-Jun-14 20:17pm
Comments
Wes Aday at 28-Jun-14 8:01am
   
How would you expect us to tell you why your query returned no results? We can't see your code, your project, your database or read your mind to know what it is that you did differently.
Aadyakumar at 30-Jun-14 8:22am
   
I had put the stored procedure in solution,since it is larger to submit here...
Wes Aday at 30-Jun-14 8:57am
   
And so? If the stored procedure works fine like you say it works, why on earth would you think that we would need to see it? If the problem is with your C# code, don't you think that it's reasonable to assume that you should be posting your C# code?
Aadyakumar at 1-Jul-14 0:40am
   
Ok,i have same doubt,but if i use another stored procedure in same location of C# code then it will work fine. why??
RyanDev at 28-Jun-14 9:53am
   
There is no way for us to know what you did wrong unless you click on Improve question and show us the relevant code.
 
If the SQL works then it sounds like it is likely a simple issue.
Aadyakumar at 30-Jun-14 8:22am
   
I had put the stored procedure in solution,since it is larger to submit here...
RyanDev at 30-Jun-14 8:26am
   
Don't post as solution because it is NOT a solution. Click on Improve question and add only the relevant code.
hnonght at 30-Jun-14 22:05pm
   
i have same question
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

This article[^] may help you.
 
You need to debug through your connection to SQL Server to see if the data is being returned from your query, make sure the parameters you are passing in are valid values.
  Permalink  
Comments
Aadyakumar at 1-Jul-14 7:15am
   
The parameters are ok,and the stored procedure is working (ie,i had checked by saving the out put in a table).
But it is not coming in the C# program .
If i replace another Stored procedure and its parameter(only procedure name and parameter,no more changes) then out put will come .
How it happens ???
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

I solved it temporary, as
i altered the Procedure and tried to save the output to a dynamic table (Using select * into) . Then i check the dynamic table after the program execution ,i found the out put is saved in that dynamic table .

Then i read the data of this dynamic table using another procedure .

Thanks&Regards,
Aadyakumar.D.V
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,935
1 OriginalGriff 6,987
2 CPallini 5,845
3 George Jonsson 4,015
4 Gihan Liyanage 3,266


Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 20 Aug 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100