两个数据集-一个下拉列表..(VB.NET) [英] Two Data Sets - One Drop Down List.. (VB.NET)

查看:56
本文介绍了两个数据集-一个下拉列表..(VB.NET)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有两个不同的数据集.
一号包含:
ID(主键),名称,姓氏,AreaCode(外键)
第二个包含:
AreaCode(主键),AreaName

现在我要在下拉列表中列出所有区域的名称,
但我想显示已为特定ID选择的区域.

因此,当我加载应用程序时,已选择的区域会显示为id 001
要显示(且该信息位于数据集1中)
当我单击以查看列表时,我想查看区域名称(该信息位于数据集2中)
================================================== =====================

我知道内部联接的SQL语句如下所示

Hi Folks,

I''ve got two different data sets.
Number One Contains:
ID(Primary Key), Name, Surname, AreaCode(Foreign Key)
Number Two Contains:
AreaCode(Primary Key), AreaName

Now I want to have all the area''s names in my dropdownlist,
but I want to display the area that has been selected for a certain id.

So when I load the app the Area that has been selected say For id 001
to be displayed (and that info is in DataSet 1)
And when i click to see the list i want to see the Area names (and that info is in DataSet 2)
========================================================================

I know about the inner join my SQL Statement looks like this

MainDataTable = Populate("SELECT " _
+ "tblJobReq.Job_ID, tblJobReq.Date, tblArea.Area_Name, " _
+ "tblEmployee.FirstNames + ' ' + tblEmployee.Surname AS Operator, " _
+ "dTblEmp1.FirstNames + ' ' + dTblEmp1.Surname AS 'Requested By', " _
+ "dTblEmp2.FirstNames + ' '+ dTblEmp2.Surname AS 'Attended By' , " _
+ "tblJobReq.Time_Req, tblJobReq.Time_Att, tblJobReq.Time_Comp, " _
+ "tblJobTypes.Type, tblJobReq.Comment " _
+ "FROM tblJobReq " _
+ "INNER JOIN tblArea " _
+ "ON tblJobReq.Area_ID = tblArea.Area_ID " _
+ "INNER JOIN tblJobTypes " _
+ "ON tblJobReq.Job_Type = tblJobTypes.[Job ID] " _
+ "INNER JOIN tblEmployee " _
+ "ON tblJobReq.CRO_ID = tblEmployee.EmployeeID " _
+ "INNER JOIN(SELECT EmployeeID, FirstNames, Surname " _
+ "FROM tblEmployee AS tblEmployee_1) AS dTblEmp1 " _
+ "ON tblJobReq.Req_ID = dTblEmp1.EmployeeID " _
+ "INNER JOIN (SELECT EmployeeID, FirstNames, Surname " _
+ "FROM tblEmployee AS tblEmployee_2) AS dTblEmp2 " _
+ "ON tblJobReq.Att_ID = dTblEmp2.EmployeeID ")



但是我的应用程序应该模拟一个ms访问表单,您可以在其中看到选择的内容,但是当您单击下拉菜单进行更改时,它仅在区域表中显示该选项.例如,

当我使用此数据表时,下拉菜单包含重复项,并且我不想要



But my application should emulate an ms access form, where you can see what is selected but when you click the dropdownmenu to change it the it only displays the option in the area table for example.

when I use this datatable the dropdown menu contains duplicates, and that I don''t want

推荐答案

您需要做的是使用内部联接编写SQL包含两个表中数据的语句,并通过AreaCode链接.我不能在不知道表名的情况下编写它,但是这是在SQL最基本的SQL技术中的一个很好的练习,它使您可以进行一些研究并自己想出办法.如果您没有书,则需要使用SQL INNER JOIN进行Google搜索.
What you need to do is use an inner join to write a SQL statement that contains the data from both tables, linked via the AreaCode. I can''t write it without knowing the table names, but it would be a good exercise in the most basic of SQL techniques for you to do some research and come up with it yourself anyhow. SQL INNER JOIN is what you need to google, if you have no book.


如果我正确理解了您的问题,则会使用SQL语句(例如这个:

If I''m understanding your problem correctly, I''d load the dropdown control with an SQL statement like this:

SELECT DISTINCT AreaCode, AreaName FROM tblArea



将下拉列表的值设置为AreaCode并显示为AreaName.然后根据您的MainDataTable(另一个SQL语句)中的数据,在下拉列表中选择当前保存的选项.



Set the dropdown''s value to AreaCode and display to AreaName. Then based on the data in your MainDataTable (a different SQL statement) select the currently saved option in the dropdown.


这篇关于两个数据集-一个下拉列表..(VB.NET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆