使用LINQ中的存储过程将数据导入文本框

时间:2016-02-11 16:37:49

标签: c# asp.net sql-server linq-to-sql

我想使用存储过程将数据放入文本框中:

var q = objcontext.sploadloandata(comboBox1.Text);
txtcustname.Text = "what to do here";
txtaddress.Text = "what to do here";
txtmobile.Text = "what to do here";
txtemailid.Text = "what to do here";

此代码是我的存储过程,请检查并解决此问题

alter proc sploadloandata
    @customerid nvarchar(50)
as
begin
    declare @today datetime
    SET @today = dateadd(day, datediff(day, 0, current_timestamp), 0)

    select 
        a.custid, b.name, b.mobile, b.phone, a.eligibleamt, 
        a.loanamt, a.interest, a.validity,
        datediff(day, a.cdate, @today) as No_Of_Days,
        round(a.loanamt * a.interest * datediff(day, a.cdate, @today) / 36500, 2) as SI,
        round(a.loanamt * a.interest * datediff(day, a.cdate, @today) / 36500, 2) + a.loanamt as CHECKsi
    from 
        tblLoanEntrydetails a, tbl_customer b
    where 
        a.custid = b.cid 
        and b.cid = @customerid
    order by 
        a.fororderdate desc
end

1 个答案:

答案 0 :(得分:0)

我找到了正确的解决方案...... 请检查一下......

首先替换我写的查询

Old Query : var q = objcontext.sploadloandata(comboBox1.Text);
New Query :  var q = (from data1 in objcontext.sploadloandata(comboBox1.Text)
                select data1).FirstOrDefault();

现在,我将所有数据都放入文本框

txtcustname.Text = q.name;
txtnetweight.Text = q.weight;
txtmobile.Text = q.mobile;
txtloanamt.Text = q.loanamt;