没有获得所需的输出。它返回“没有记录“ [英] Not getting the desired output . It returns" no records"

查看:60
本文介绍了没有获得所需的输出。它返回“没有记录“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void Page_Load(object sender,EventArgs e)

{

///加载开始

if(!IsPostBack)

{

尝试

{



SqlConnection connect = new SqlConnection();

connect.ConnectionString = ConfigurationManager.ConnectionStrings [ApplicationServices]。ConnectionString;

connect.Open();

SqlDataAdapter da = new SqlDataAdapter( @SELECT APPROVED_MAINTENANCE。*,

CURRENCY.CURR_BUY作为ZEXCHANGE

来自APPROVED_MAINTENANCE

LEFT JOIN CURRENCY APPROVED_MAINTENANCE.APP_CURR = CURRENCY.CURR_SHORT

WHERE APPROVED_MAINTENANCE.FACILITY_STATUS

NOT IN('已发布','拒绝')

订购APPROVED_MAINTENANCE.APPRAISAL_NO,连接);



// SqlDataAdapter da = new SqlDataAdapter(@SELECT APPROVED_MAINTENANCE。*

// FROM APPROVED_MAINTENANCE

// ORDER BY APPRAISAL_NO ,连接);





DataSet ds = new DataSet();

da.Fill(ds, APPROVED_MAINTENANCE);





if(ds.Tables [0] .Rows.Count == 0)

{



lblStatus.Text =表中没有记录;



// Response.Redirect(〜/ main_form.aspx);



}

其他

{



txt_Actual_Loan.Text = ds。表[APPROVED_MAINTENANCE]。行[0] [Appraisal_No]。ToString();

txt_Appraisal_No.Text = ds.Tables [APPROVED_MAINTENANCE]。行[0] [CREDNO ] .ToString();

txt_DFI_Code.Text =;

txt_DFI_Name.Text =



< b>我尝试了什么:



这是一个代码段,可以用另一种形式运行。

protected void Page_Load(object sender, EventArgs e)
{
///Load Begin
if (!IsPostBack)
{
try
{

SqlConnection connect = new SqlConnection();
connect.ConnectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
connect.Open();
SqlDataAdapter da = new SqlDataAdapter(@"SELECT APPROVED_MAINTENANCE.* ,
CURRENCY.CURR_BUY AS ZEXCHANGE
FROM APPROVED_MAINTENANCE
LEFT JOIN CURRENCY ON APPROVED_MAINTENANCE.APP_CURR=CURRENCY.CURR_SHORT
WHERE APPROVED_MAINTENANCE.FACILITY_STATUS
NOT IN ('DISBURSED','DENIED')
ORDER BY APPROVED_MAINTENANCE.APPRAISAL_NO", connect);

// SqlDataAdapter da = new SqlDataAdapter(@"SELECT APPROVED_MAINTENANCE.*
// FROM APPROVED_MAINTENANCE
// ORDER BY APPRAISAL_NO", connect);


DataSet ds = new DataSet();
da.Fill(ds, "APPROVED_MAINTENANCE");


if (ds.Tables[0].Rows.Count == 0)
{

lblStatus.Text = "No Records in the Table";

// Response.Redirect("~/main_form.aspx");

}
else
{

txt_Actual_Loan.Text = ds.Tables["APPROVED_MAINTENANCE"].Rows[0]["Appraisal_No"].ToString();
txt_Appraisal_No.Text = ds.Tables["APPROVED_MAINTENANCE"].Rows[0]["CREDNO"].ToString();
txt_DFI_Code.Text = " ";
txt_DFI_Name.Text =

What I have tried:

This is a code segment which is working ok in another form.

推荐答案

首先查看数据库并检查是否有行要返回。

将查询粘贴到SQL Server Management Studio中作为D的新查询B并运行它。

你得到什么?什么?我猜不到 - 但我们无法访问你的数据库,所以我们无法检查!



如果你没有得到行,删除WHERE条件然后再试一次。继续拿出比特,直到你得到行,然后查看你的数据,找出为什么有用。



我们可以为你做任何事情:它需要你的数据库检查,我们没有。
So start by looking at your database and checking that there are rows to return.
Paste your query into SQL Server Management Studio as a new query on your DB and run it.
What do you get? Anything? I'm guessing none - but we have no access to your DB, so we can't check!

If you don't get rows, remove the WHERE condition and try again. Keep taking bits out until you do get rows, then look at your data to work out why that worked.

We can;t do any of that for you: it needs your DB to check against, and we don't have it.


这篇关于没有获得所需的输出。它返回“没有记录“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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