내 배경은 다음과 같습니다. 사용자가 입력을 시작하면 데이터베이스 테이블의 열에서 제안 된 항목을 검색해야하는 콤보 상자가 있습니다.Access 데이터베이스 C# 쿼리 문제
try{
String temp = nameCBox.Text;
AutoCompleteStringCollection namesSuggestion = new AutoCompleteStringCollection();
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source=C:\\LogEntry\\LogEntry.accdb; Persist Security Info = False;");
OleDbDataReader reader;
conn.Open();
String text2send = "Select Name from [Teachers] where FName like '" + temp + "' OR LName like '" + temp + "' Group by [Name]";
OleDbCommand cmd = new OleDbCommand(text2send, conn);
reader = cmd.ExecuteReader();
if (reader.HasRows == true)
{
while (reader.Read())
namesSuggestion.Add(reader["temp"].ToString());
}
reader.Close();
nameCBox.AutoCompleteCustomSource = namesSuggestion;
conn.Close();
}
오류 : 사용자 이름을 inputing 시작하고 프로그램 이름과 성을 모두보고 이름을 제안한다 (데이터베이스가 모두 별도의 테이블이) 여기
은 내가 가진 코드는 1) 콤보 상자에 아무런 제안이 없습니다. 2) 콤보 상자에 입력하면 텍스트가 강조 표시되고 다른 내용을 다시 입력하면 이전에 입력 한 문자에 쓰여집니다.이 desktopmaker
첫 번째 제안 : 매개 변수가있는 쿼리를 사용하십시오. http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbparameter%28v=vs.100%29.aspx – varg