一个零件包装相关的问题,数据库中有4张表:零件表:零件号(*)、零件名称...;箱子表:箱号(*)、重量...;进货包装表:零件号(*)、箱号、每箱数量...;出运包装表:零件号(*)、箱号、每箱数量...。*号的为主键。现在要维护进货和出运的信息,想达到以下目的:有个组合框或者别的什么的,显示出所有的零件号,选择好后,一方面显示该零件的信息(在这里只能看不能更改,零件的维护是在另外的窗体中),另一方面显示进货和出运包装的信息,要求能看,并且安全更改。能看的意思是:比如选了进货按钮,则显示出箱号是1,另外某个文本框立即显示出1号箱的重量。能安全更改的意思是:显示箱号的也是个组合框或者别的什么控件,我现在想换个箱子,可以下拉后从现有的所有箱子中选择,比如选了2号箱,这个文本框也立即显示出2号箱的重量。要求如上所述,不知该用什么控件来实现这些表间的连接和绑定关系???如果得用ado什么的我还不太懂,各位高手能否说的详细点?或者给些代码示范,问题解决即给分,先谢过了!!!

解决方案 »

  1.   

    I don't think you can get away with just using some VB data controls.  You need to write some data access codes to get it done.  Either ADO or DAO.  ADO is the preferred way to do data access right now.Don't say you don't know SQL.  ADO is rather easy to code.  M$ always makes things easier for developers.  In ADO,
    Create a Connection object to the database.  You can hardcode the server and database name or use an ODBC name that you setup thru Control Panel -> Data Source (ODBC).
    Do a execute of an SQL statement on the Connection object to get a ResultSet object for the data you want.
    Iterate thru the resultset to get what you want.
    close the resultset
    close the connectionThis is the basic idea of ADO.  Just like any other data access codings.For the GUI part, you can use DataGrid or ListView.  Use the appropriate event (User Select event) to execute the above ADO thing to populate the second GUI control.That's basically it.  Sorry cannot give you any codes as I am away from my VB box.