本文介绍了使用数据集热填充结果到存储过程的下拉列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Hi,

ALTER procedure  [dbo].[sp_inout]
(
@companyid bigint,
@contactid bigint,
@invoiceid int,
@currency char(3)
)
as 
begin
declare @in  varchar(50)
declare @out varchar(50)
select @in =0
select @out=0
select @in=sum(cast(c.total_amount as int)) from t_cust_inout c, t_invoice inv where
c.invoice_id=inv.invoice_id and c.contact_id=@contactid and c.inout=0 and c.invoice_id=@invoiceid and 
c.company_id=@companyid
if (@in is null)
begin
	select @in=0
end
select @out=sum(cast(c.total_amount as int)) from t_cust_inout c, t_invoice inv where
c.invoice_id=inv.invoice_id and c.contact_id=@contactid and c.inout=1 and c.invoice_id=@invoiceid and 
c.company_id=@companyid
------------
IF OBJECT_ID('tempdb..#tempinout') IS NOT NULL
begin
	drop table #tempinout
end
-----------
if (@in<>@out)
begin
	create table #tempinout
	(
	invoiceid  int,
	invoiceno  varchar(50)
	)
	---------
	insert into #tempinout
	select inv.invoice_id,inv.invoice_number +' - '+@currency+'. '+ cast((cast(@out as decimal)- cast(@in as decimal)) as varchar) 
	from t_invoice as inv where inv.invoice_id=@invoiceid
select * from #tempinout
drop table #tempinout
end

end


我用了这个sp.值未绑定到数据集中.任何人都可以帮助我.


I used this sp. Values are not bind in dataset. Anyone can help me plz.

cmdq2.Dispose()
                    cmdq2.Parameters.Clear()
                    cmdq2.Connection = con
                    cmdq2.CommandType = CommandType.StoredProcedure
                    cmdq2.CommandText = "sp_inout"
                    cmdq2.Parameters.Add("@companyid", SqlDbType.BigInt).Value = Session("maincompanyid")
                    cmdq2.Parameters.Add("@contactid", SqlDbType.BigInt).Value = Session("Customer_id")
                    cmdq2.Parameters.Add("@invoiceid", SqlDbType.Int).Value = Session("y1")
                    cmdq2.Parameters.Add("@currency", SqlDbType.Char).Value = currency


Dim da1 As New SqlDataAdapter(cmdq2)
Dim ds1 As New DataSet
da1.Fill(ds1)
ddlinv.DataSource = ds1
ddlinv.DataTextField = "invoiceno"
ddlinv.DataValueField = "invoiceid"
ddlinv.DataBind()



[edit]已添加到SQL SP的代码块-OriginalGriff [/edit]



[edit]Code block added to SQL SP - OriginalGriff[/edit]

推荐答案

ddlinv.DataSource = ds1



而是:



Instead do:

ddlinv.DataSource = ds1.Tables[0];


这篇关于使用数据集热填充结果到存储过程的下拉列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 20:11