나는 mcID를 사용하여 서로 관계가있는 약속 테이블과 의료 센터 인 두 개의 테이블을 가지고 있습니다. 지금 내 약속 양식, 나는 gridview mcID 대신 medicalcentre 테이블에 mcCentre 표시하려면 외부 조인을 사용합니다. 내 양식에 보면 모든 의료 센터 (mcCentre)가 gridview에 표시됩니다. 그러나 황 황산 가족 클리닉의 텍스트 상자에있는 텍스트와 일치시키려는 경우에만 황 및 리앙 패밀리 클리닉 기록을 표시하고 싶습니다. 즉, 병원 텍스트가 텍스트 상자에 있다면 병원 기록이 그리드 뷰에 표시되기를 바랍니다. 텍스트 상자 이름은 txtCentre입니다.텍스트 상자의 텍스트를 일치시켜 레코드를 표시하는 방법은 무엇입니까?
private void LoadAppointmentRecords()
{
//retrieve connection information info from App.config
string strConnectionString = ConfigurationManager.ConnectionStrings["SACPConnection"].ConnectionString;
//STEP 1: Create connection
SqlConnection myConnect = new SqlConnection(strConnectionString);
//STEP 2: Create command
//string strCommandText = "SELECT appointmentID, convert(varchar, aDate, 103) AS aDate, aTime, aStatus, aContact, aHeight, aWeight, patientID, mcID, nurseID FROM APPOINTMENT";
string strCommandText = "SELECT appointmentID, convert(varchar, aDate, 103) AS aDate, aTime, aStatus, aContact, aHeight, aWeight, pat.pFirstName, pat.pLastName, cen.mcCentre, nur.nUsername FROM APPOINTMENT AS app";
strCommandText += " LEFT OUTER JOIN PATIENT as pat on app.patientid = pat.patientid";
strCommandText += " LEFT OUTER JOIN MEDICALCENTRE as cen on app.mcid = cen.mcid";
strCommandText += " LEFT OUTER JOIN NURSE as nur on app.nurseid = nur.nurseid";
//strCommandText += " LEFT OUTER JOIN NURSE as nur on app.nurseid = nur.nurseid";
AppointmentAdapter = new SqlDataAdapter(strCommandText, myConnect);
//command builder generates Select, update, delete and insert SQL
// statements for MedicalCentreAdapter
//SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(AppointmentAdapter);
// Empty Employee Table first
Appointment.Clear();
// Fill Employee Table with data retrieved by data adapter
// using SELECT statement
AppointmentAdapter.Fill(Appointment);
// if there are records, bind to Grid view & display
if (Appointment.Rows.Count > 0)
grdApp.DataSource = Appointment;
}