2013-09-03 2 views
1

데이터베이스에서 값을 검색하고 databaseshow에서 값을 삭제하고 싶습니다. 나는 검색 할 수 있지만 내가 삭제 버튼을 클릭 할 때의 나에게 다음과 같은 오류 제공 :데이터베이스에서 문자열 값을 검색하고 DataGridView에서 표시하려면 어떻게해야합니까?

private void sID_textBox7_TextChanged_1(object sender, EventArgs e) 
     { 
      try 
      { 
       BindingSource bs = new BindingSource(); 
       bs.DataSource = dataGridView4.DataSource; 
       bs.Filter = "[Product ID]=" + sID_textBox7.Text.ToString(); 
       dataGridView1.DataSource = bs; 
      } 
      catch (Exception ex) 
      { 
       MessageBox.Show(ex.Message); 
      } 
     } 
+2

필터가 'Product ID = SomeText'와 (과) 닮았습니다. 'Product ID = 'SomeText''와 같이 사용해야합니다. –

답변

0

방금 ​​전에 필터 값 후 '을 놓친 :

Syntex error:missing operand after '='.

을 여기에 내 코드입니다.

[Product ID] = SomeText

[Product ID] = 'SomeText'

private void sID_textBox7_TextChanged_1(object sender, EventArgs e) 
    { 
     try 
     { 
      BindingSource bs = new BindingSource(); 
      bs.DataSource = dataGridView4.DataSource; 
      bs.Filter = "[Product ID]=" + "'" + sID_textBox7.Text + "'"; 
      dataGridView1.DataSource = bs; 
     } 
     catch (Exception ex) 
     { 
      MessageBox.Show(ex.Message); 
     } 
    } 

BindingSource.Filter Property

편집

sID_textBox7.Text.ToString() 더 SENS가 없습니다 쓰기를 참조해야한다. .Text 속성은 String을 반환하므로 .ToString()을 사용할 필요가 없습니다.

+1

올바르게 작동 함 – mahfuz110244

관련 문제