本文介绍了SQL搜索到Label的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 谁将帮助我继续使用>>>> ????<<<<<<下面... 在这个项目中,我正在看表Klanten 在KlantenBOXfilteren()中,我在列表框中搜索我的记录。在选择客户端(通过名称naam显示)后,我得到一个ID。 在KlantenContactBOX()我使用ID字段(再给manny一个关系)搜索来自客户的所有联系人 现在我想在KlantenInfo()中制作类似的解决方案我想加载客户表有多个标签。 中的示例字段 表文件名Labelname Naam = LB_KlantenNaam Adres = LB_KlantenAdres Telefoon = LB_KlantenTelefoon 我需要什么代码写在>>>> ????<<<<< private void KlantenBOXfilteren() { string queryZoekOrganisatie =Select * From Klanten WHERE Organisatie like @ZoekOrganisatie ; 使用(connection = new SqlConnection(connectionstring)) using(SqlCommand command = new SqlCommand(queryZoekOrganisatie,connection)) using(SqlDataAdapter adapter = new SqlDataAdapter(command)) { command.Parameters.AddWithValue(@ ZoekOrganisatie,%+ TX_KlantenZoeken.Text +%); DataTable Klantenlijst = new DataTable(); adapter.Fill(Klantenlijst); ListBoxKlanten.DisplayMember =Organisatie; ListBoxKlanten.ValueMember =ID Klanten; ListBoxKlanten.DataSource = Klantenlijst; } } // Klanten联系人personen private void KlantenContactBOX() { string queryKLantID =select * From Klantencontact WHERE FK_ID_Klant = @SELKlantID; 使用(connection = new SqlConnection(connectionstring)) using(SqlCommand command = new SqlCommand(queryKLantID,connection)) using(SqlDataAdapter adapter = new SqlDataAdapter(command)) { command.Parameters.AddWithValue(@ SELKlantID,ListBoxKlanten.SelectedValue); DataTable KlantenContactlijst = new DataTable(); adapter.Fill(KlantenContactlijst); listBoxKlantenContact.DisplayMember =Naam; listBoxKlantenContact.ValueMember =FK_ID_klant; listBoxKlantenContact.DataSource = KlantenContactlijst; } } // klant informatie inzien private void KlantenInfo() { string queryKLantinfoID =select * From Klanten WHERE ID Klanten = @SELKlantinfoID; 使用(connection = new SqlConnection(connectionstring)) using(SqlCommand command = new SqlCommand(queryKLantinfoID,connection)) using(SqlDataAdapter adapter = new SqlDataAdapter(command)) { command.Parameters.AddWithValue(@ SELKlantinfoID,ListBoxKlanten.SelectedValue); >>>> ????<<<<< } } 解决方案 Who will help me continue with the code at ">>>>????<<<<<" below...In this project, I'm looking at the table "Klanten" At "KlantenBOXfilteren()" I search my record in a listbox. After selecting the client (visualized by name "naam") I get back an ID.At "KlantenContactBOX()" I use the ID field ( one more to manny relationship ) to search for all contacts from the customer Now I would like to make a similar solution in "KlantenInfo()" I want to load the fields from the " customer table " in multiple labels.Example fields in Table filename LabelnameNaam = LB_KlantenNaamAdres = LB_KlantenAdresTelefoon = LB_KlantenTelefoonWhat code do I need to write at ">>>>????<<<<<" private void KlantenBOXfilteren() { string queryZoekOrganisatie = "Select * From Klanten WHERE Organisatie like @ZoekOrganisatie"; using (connection = new SqlConnection(connectionstring)) using (SqlCommand command = new SqlCommand(queryZoekOrganisatie, connection)) using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { command.Parameters.AddWithValue("@ZoekOrganisatie", "%" + TX_KlantenZoeken.Text + "%"); DataTable Klantenlijst = new DataTable(); adapter.Fill(Klantenlijst); ListBoxKlanten.DisplayMember = "Organisatie"; ListBoxKlanten.ValueMember = "ID Klanten"; ListBoxKlanten.DataSource = Klantenlijst; } } //Klanten Contact personen private void KlantenContactBOX() { string queryKLantID = "select * From Klantencontact WHERE FK_ID_Klant = @SELKlantID"; using (connection = new SqlConnection(connectionstring)) using (SqlCommand command = new SqlCommand(queryKLantID, connection)) using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { command.Parameters.AddWithValue("@SELKlantID", ListBoxKlanten.SelectedValue); DataTable KlantenContactlijst = new DataTable(); adapter.Fill(KlantenContactlijst); listBoxKlantenContact.DisplayMember = "Naam"; listBoxKlantenContact.ValueMember = "FK_ID_klant"; listBoxKlantenContact.DataSource = KlantenContactlijst; } } //klant informatie inzien private void KlantenInfo() { string queryKLantinfoID = "select * From Klanten WHERE ID Klanten = @SELKlantinfoID"; using (connection = new SqlConnection(connectionstring)) using (SqlCommand command = new SqlCommand(queryKLantinfoID, connection)) using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { command.Parameters.AddWithValue("@SELKlantinfoID", ListBoxKlanten.SelectedValue); >>>>????<<<<< } } 解决方案 这篇关于SQL搜索到Label的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-30 00:40