쿼리를 삭제하는 것과 유사한 구문을 사용하고 있지만 테이블이 있는지 확인하고 삭제하려고하면 테이블이 실제로 삭제되지 않습니다. 단계가 빠지거나 잘못된 구문을 사용 했습니까?코드가 테이블을 삭제하지 않음
string path = "C:\\Database\\EmployeeInfo\\EmpInfo.mdb";
bool found = false;
DAO.DBEngine db = new DAO.DBEngine();
dd = db.OpenDatabase(path);
try
{
string[] tableNames = new string[3]
{
supName + "_Profile1",
supName + "_Profile2",
supName + "_Profile3",
};
for (int q = tableNames.GetLowerBound(0); q <= tableNames.GetUpperBound(0); q++)
{
foreach (DAO.TableDef tabledef in dd.TableDefs)
{
string newName = Convert.ToString(q);
if (tabledef.Name == newName)
{
found = true;
}
if (found)
{
dd.TableDefs.Delete(newName);
}
}
}
}
편집 --- 간단한 구문 실수는 .... 코드가 있었어야 :
string newName = tableNames[q];
'dd.TableDefs'를 반복하면서'dd.TableDefs'를 수정할 수 없습니다. – crashmstr
Grrr ... 여러 개의 테이블 이름을 확인할 수있는 임시 해결책이 있습니까? – MasterOfStupidQuestions
@ Vkt0rS. 여기서했던 것처럼 중괄호를 지우면 아무 것도 개선하지 못했습니다. 모든 제어문에 중괄호를 사용하면 한 줄이라도 완벽하게 합법적 인 (내 의견으로는 유익한) 실습입니다. – JLRishe