带有Sql存储过程的C#程序(带有pivoting和Dynamic quires) [英] C# Program with Sql Stored Procedure (with pivoting and Dynamic quires)

查看:85
本文介绍了带有Sql存储过程的C#程序(带有pivoting和Dynamic quires)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



我的C#.Net-Sql程序中有这种情况。



我想为我的新公司创建一个excel报告,在基于其他主表条件的报告列数中,主表条目也应该是列标题。因此需要旋转主表(2次)。 />
所以我按照以下方式进行操作:

1)创建带参数的存储过程。

2)从C#执行存储过程并读取/存储表格格式化数据在C#DataTable中。

3)将DataTable值打印到Excel。



所以我创建一个存储过程,当我在sql server中运行它工作正常,表结构化输出正在按预期进行。



现在我试图从C#运行它,DataTable填充结果0行0列。



为什么会发生这种情况???



我有一个临时解决方案,因为
i改变了过程并尝试将输出保存到动态表(使用select * into)。然后我在程序执行后检查动态表,我发现输出保存在那个动态表中。



然后我用另一个读取这个动态表的数据程序。



谢谢和问候,

Aadyakumar.DV

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

推荐答案

这个文章 [ ^ ]可能对您有所帮助。



您需要通过与SQL Server的连接进行调试,以查看是否从查询中返回数据,确保传入的参数是有效值。
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.


我暂时解决了它,因为
i改变了Procedure并尝试将输出保存到动态表(使用select * into)。然后我在程序执行后检查动态表,我发现输出保存在那个动态表中。



然后我用另一个读取这个动态表的数据程序。



感谢和问候,

Aadyakumar.DV
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


这篇关于带有Sql存储过程的C#程序(带有pivoting和Dynamic quires)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆