1
콤보 상자를 채우는 데 문제가 있습니다. 간단한 선택 쿼리를 하나 채울 수 있습니다. 이제 where 명령을 포함하는 쿼리로 콤보 상자를 채우고 싶습니다. 몇 가지 해결책을 시도했지만 그 중 아무 것도 효과가 없었습니다. Where 문을 사용하여 쿼리로 콤보 상자를 채울 수 있습니까?where 명령 (VB.NET)을 사용하여 쿼리를 사용하여 콤보 상자 채우기
내 코드는 지금까지 있습니다 :
Public Function vulComboboxTesten(box As ComboBox, naam As String) As ComboBox
box.Items.Clear()
box.Items.Add(" ")
Dim query As String
query = "Select Sector from Onderaannemers where Naam_firma = @naam "
Debug.WriteLine(query)
Dim command As OleDbCommand
command = New OleDbCommand(query, connectie)
command.Connection.Open()
Dim datareader As OleDbDataReader
datareader = command.ExecuteReader
While datareader.Read
Dim item As New ComboBoxItem
item.Content = datareader("Sector")
box.Items.Add(item)
End While
command.Connection.Close()
Return box
End Function
'Onderaannemers에서 섹터를 선택하십시오. 여기서 Naam_firma = @ naam'이 문제입니다. 매개 변수를 쿼리에 추가했지만 쿼리에 매개 변수를 포함시키지 마십시오 ... – Codexer
어떻게 처리해야합니까? – Messiaeno
다음과 같은 명령입니다 :'command.Parameters.Add (새 OleDbParameter ("@ naam", naam-yourvalue))'*** *** command = New OleDbCommand (query, connectie)'다음에 이것을하십시오. 또 다른 메모에서 데이터베이스를 때 연결을 처분하는 것이 중요합니다, 나는 처분받을 수 있도록 사용하여 성명서에 명령과 연결을 래핑하는 것이 좋습니다 것이 좋습니다. – Codexer