动态数据未显示在数据库中 [英] dyanamic data is not getting displayedin database
本文介绍了动态数据未显示在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
查询为bellw
创建proc FetchInvoice
(@invoiceNo数字( 10 ))
为
开始
选择c.CompanyName,c.ExciseNo,c.VATNo,c.CSTNo,c.CompanyId,
com.AddressId,com.AddressLine1,com.CompanyCity,com.Country,com.Pin,com.State,
cust.Cust_First_Name,cust.Cust_Last_Name,cust.ContactNo,cust.EmailId,
h.CustomerPONo,h.Fi_Year,h.FinalInvoicePrice,
h.FinalInvoicePrice_WithoutRO,h.inv_date,h.invoice_no,
h.RO_Fact,h.TaxPrice,h.TaxTerms,h.CompanyId,
l.Item,l.Description,l.Quantity,l.TeriffClass,l.Unite_Price,l.Total_Price
来自company_master c
内部联接
companyaddress AS Com
开启c.CompanyId = Com.AddressId
INNER JOIN客户地址按
在c.CompanyId = cust.Cust_Add_Id上
内部加入标头 as h
在c.CompanyId = h.CompanyId上
内部加入 invoiceItems as l
在h.invoice_no = l.invoice_no上
其中 h.invoice_no=@invoiceNo
结束
我用来显示此报告的代码如下所示
int invNo = 1 ;
SqlConnection con = 新 SqlConnection(CS);
SqlCommand cmd = 新 SqlCommand();
TaxInvoice ds = 空;
SqlDataAdapter适配器;
尝试
{
con.Open();
cmd.CommandText = " ;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(" ,invNo);
cmd.Connection = con;
cmd.ExecuteNonQuery();
ds = 新 TaxInvoice();
adapter = 新 SqlDataAdapter(cmd);
adapter.Fill(ds);
ReportDocument rd = 新 ReportDocument();
rd.Load(Server.MapPath(" ));
rd.SetDataSource(ds.Tables [ 1 ]);
CrystalReportViewer1.ReportSource = rd;
}
捕获(例外)
{
抛出 新异常(例如消息);
}
但最后我得到的是空报告
关于这个问题,有人可以帮我吗?
预先感谢
解决方案
ExecuteNonQuery不返回行数据,仅返回受影响的行数.
请参阅以下链接;
执行非查询文档
我建议使用ExecuteReader-请参阅以下链接;
执行阅读器文档
>
im trying to display data from multiple tablesinto single report with the simple query with joins but when i am running bpage then the crystal report is completly empty means its not fetching data from database,but when i am execeuting that query in sql server it shows me a proper result
the query is as bellw
create proc FetchInvoice
(@invoiceNo numeric(10) )
as
begin
SELECT c.CompanyName,c.ExciseNo,c.VATNo,c.CSTNo,c.CompanyId,
com.AddressId,com.AddressLine1,com.CompanyCity,com.Country,com.Pin,com.State,
cust.Cust_First_Name,cust.Cust_Last_Name,cust.ContactNo,cust.EmailId,
h.CustomerPONo,h.Fi_Year,h.FinalInvoicePrice,
h.FinalInvoicePrice_WithoutRO,h.inv_date,h.invoice_no,
h.RO_Fact,h.TaxPrice,h.TaxTerms,h.CompanyId,
l.Item,l.Description,l.Quantity,l.TeriffClass,l.Unite_Price,l.Total_Price
FROM company_master c
INNER JOIN
companyaddress AS Com
ON c.CompanyId=Com.AddressId
INNER JOIN customeraddress as cust
on c.CompanyId=cust.Cust_Add_Id
inner join Header as h
on c.CompanyId=h.CompanyId
inner join invoiceItems as l
on h.invoice_no=l.invoice_no
where h.invoice_no=@invoiceNo
end
and the code which i am using to show this report is as bellow
int invNo = 1;
SqlConnection con = new SqlConnection(CS);
SqlCommand cmd = new SqlCommand();
TaxInvoice ds = null;
SqlDataAdapter adapter;
try
{
con.Open();
cmd.CommandText = "FetchInvoice";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@invoiceNo", invNo);
cmd.Connection = con;
cmd.ExecuteNonQuery();
ds = new TaxInvoice();
adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds);
ReportDocument rd = new ReportDocument();
rd.Load(Server.MapPath("Invoicereport.rpt"));
rd.SetDataSource(ds.Tables[1]);
CrystalReportViewer1.ReportSource = rd;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
but at the end i am getting is empty report
can any one help me regarding this issue??
thanks in advance
解决方案
ExecuteNonQuery does not return row data, only the number of rows affected.
Refer to the below link;
Execute Non Query Documentation
I would recommend using ExecuteReader - refer to the below link;
Execute Reader Documentation
这篇关于动态数据未显示在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文