2012-01-31 3 views
1

SQL 문을 기반으로 데이터를 표시하려고하는 중계기가 있습니다. 그러나 리피터에 동일한 항목이 여러 행으로 표시되는 경우 어떤 이유로 하나만 표시됩니다. 데이터베이스 (인포믹스)에서.net 리피터가 중복 데이터를 제거합니다.

:

  • 급여 공제 250.00
  • 급여 공제 250.00
  • 급여 공제 250.00
  • 급여 공제 250.00
  • 학생 건강 보험 1100.00 예를 들어
,

는 리피터 표시 :

  • 급여 공제 250.00
  • 학생 건강 보험 1100.00

이 될 수있는 이유는 어떤 생각을? 코드에서 사용하는 SQL (아래)은 데이터베이스에서 실행할 때 잘 작동합니다. 데이터 테이블은 리피터 (를 Page_Load)에 결합되는 경우 여기

private DataTable GetCreditData (string id, string sessyr) 
    { 
     OdbcConnection conn = new OdbcConnection (); 
     conn.ConnectionString = cxConnStr; 

     // Define our SQL 
     String sql = "select ABS(t1.amt) as amt , t2.txt from subtr_rec t1, subt_table t2 where t1.subs = 'S/A' and t1.tot_prd = ? and t1.subs_no=? and t1.amt < 0 and t1.tot_code = t2.tot_code and t1.subs = t2.subs UNION select t1.amt, t2.txt from aid_rec t1 join aid_table t2 on t1.aid=t2.aid where t1.sess =? and t1.yr = ? and t1.id = ? and ((stat='A' and amt_stat='AA') or (stat='I' or amt_stat='AA'))"; 

     // Command 
     OdbcCommand command = new OdbcCommand (); 
     command.Connection = conn; 
     command.CommandText = sql; 

     command.Parameters.Add (new OdbcParameter ("sess", sessyr)); 
     command.Parameters.Add (new OdbcParameter ("id", id)); 
     command.Parameters.Add (new OdbcParameter ("sess2", CurrSess)); 
     command.Parameters.Add (new OdbcParameter ("yr", CurrentYr)); 
     command.Parameters.Add (new OdbcParameter ("id2", id)); 

     // Create a DataTable to store our Cached results. 
     DataTable dt = new DataTable (); 

     // Create a DataAdapter used to fill the DataTable 
     OdbcDataAdapter dataAdapter = new OdbcDataAdapter (); 

     // Associate the DataAdapter and select command created above 
     dataAdapter.SelectCommand = command; 

     try 
     { 
      // Open Database. 
      conn.Open (); 

      // Fill DataTable. 
      dataAdapter.Fill (dt); 
     } 
     catch (Exception ex) 
     { 
      edException.Error = ex; 
      this.ParentPortlet.ShowFeedback (FeedbackType.Message, "There was an error looking up term credits."); 
     } 
     finally 
     { 
      if (conn != null && conn.State == ConnectionState.Open) 
      { 
       // Release our resources (close db connection) 
       conn.Close (); 
      } 
     } 
     return dt; 

    } 

은 다음과 같습니다

DataTable creditdata = GetCreditData (Host, CurrSess + CurrentYr.Remove (0, 2)); 
TermCredits.DataSource = creditdata; 
TermCredits.DataBind (); 
+0

DB에 대해 SQL을 실행하여 반환되는 내용을 확인할 수 있습니까? SQL 명령 문제인지 아니면 리피터 자체인지 구분할 수 있습니다. – Bertie

+0

문제는 SQL 문에있는 연합에있었습니다. 노조는 중복을 제거하지 못하도록 "유니온 올"이어야합니다. – MogulBomb

+0

@NLarkin이 질문을 삭제해야합니다. – Magnus

답변

1

@NLarkin - 당신이 날 말하자면 사후 대답이 퍼팅 생각하지 않았 으면 . 나는 약간의 포트폴리오를 구축하려고 노력 중이며 온라인 입소문을 강화하고 싶습니다.

내 의견을 요약하면 SQL 결과물을 확인하십시오. 여기에 '움직이는 부분'이 하나 이상 있기 때문에 문제를 격리 할 수 ​​있습니다. SQL이 예상 한 출력을 생성한다면 리피터임을 알 수 있습니다. 분명히 리피터가 아니라면 SQL이라고 알 수 있습니다. :)

일반적으로 (내가 달걀을 빨아 먹을 것을 가르치 려하지 않기를 바란다.)이 레이어 분리가있을 때, 각 '레이어'가 결과를 생성한다는 것을 아래에서 확인하는 것이 좋습니다. 배고 있다.

희망이 유용하고 행복 코딩!
건배,
Chris.

관련 문제