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 ();
DB에 대해 SQL을 실행하여 반환되는 내용을 확인할 수 있습니까? SQL 명령 문제인지 아니면 리피터 자체인지 구분할 수 있습니다. – Bertie
문제는 SQL 문에있는 연합에있었습니다. 노조는 중복을 제거하지 못하도록 "유니온 올"이어야합니다. – MogulBomb
@NLarkin이 질문을 삭제해야합니다. – Magnus