Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
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
Comments
[no name] 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 30-Jun-14 8:22am    
I had put the stored procedure in solution,since it is larger to submit here...
[no name] 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 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??
ZurdoDev 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.

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.
 
Share this answer
 
Comments
Aadyakumar 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 ???
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900