使用MS访问字段的VB代码 [英] VB Code Using MS Access Fields

查看:76
本文介绍了使用MS访问字段的VB代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Visual Basic的新手,对MS Access具有中等水平的经验.

我有一个任务来构建VB​​代码,以操作链接的MS Access数据库.  

基于下面的伪代码,VB代码应该不会非常复杂,但是需要一些指导,以指导如何引用链接的MS Access DB字段并在VB中构建记录集".  

我正在寻找执行以下"VB模块伪代码"功能的VB代码.

我已经安装了Visual Studio Express 2012,并且已经建立了MS Access数据库并成功连接到MS Visual Studio解决方案.

下面是MS Access数据库中的表/字段和"pseudo"字段. VB模块的代码: 

MS Access数据库名称:Medical.accdb(带有3个表:实体,数据和结果) >

VB模块-输入

1. MS Access 实体表 按Entity_ID

排序

     (包含所有可能的实体)

    字段:

     Entity_ID(长整数)

2. MS Access 数据表 按Entity_ID,Event_State和Time_Start

排序

     (包含IP声明的原始数据)

    字段:

     Entity_ID(长整数)

     Time_Start(日期/时间)

     Time_End(日期/时间)

     Event_Type(字符)

     Event_State(长整数)

VB模块-输出

1. MS Access 结果表

     (包含结果)

     Master_Entity(长整数)

Entity_ID(长整数)

Master_Event_State(长整数)

State_Count

Duration_Difference

Gap_Difference

VB模块-伪代码

实体表

     Master_Entity = Entity_ID

    选择 数据表中的RecordSet(A),其中Entity_ID = Master_Entity

    重做 RecordSet(A) *评论:遍历Master_Entity *

的每个Event_State

          Master_Event_State = Event_State

          Master_Time_Start = Time_Start

          Master_Time_End = Time_End

          Master_Duration = Time_End – Time_Start

选择为 来自数据表的RecordSet(B),其中Entity_ID<> Master_Entity和Event_State = Master_Event_State

请完成 RecordSet(B) *评论:遍历所有其他(非主节点)实体的Event_States与Master_Entity的控件Event_State相匹配*

      State_Count = 1

                Duration_Difference = Master_Duration –(Time_End – Time_Start)

                Gap_Difference = Time_Start – Master_Time_Start

输出到结果表:Master_Entity,Entity_ID,Master_Event_State,State_Count,Duration_Difference,Gap_Difference

结束

结束

结束                

解决方案

如果您不知道从哪里开始,建议您开始研究文档. ADO.Net是.Net Framework中负责数据访问的组件: ADO.Net


I'm completely new to Visual Basic and have intermediate level experience with MS Access.

I have an assignment to build VB code to manipulate a linked MS Access database.  

The VB code should not be very complex based on my pseudo code below, but am needing some guidance into how to reference linked MS Access DB fields and build 'recordsets' in VB.  

I'm looking for the VB code that performs the functions of the 'VB Module Pseudo Code' below.

I've installed Visual Studio Express 2012 and the MS Access database has been built and successfully connected to a MS Visual Studio Solution.

Below are the tables/fields in the MS Access database and the "pseudo" code for the VB module: 

MS Access Database Name: Medical.accdb (with 3 tables: Entity, Data and Results)

VB Module - Inputs

1. MS Access Entity Table sorted by Entity_ID

     (Contains All Possible Entities)

     Fields:

     Entity_ID (Long Integer)

2. MS Access Data Table sorted by Entity_ID, Event_State and Time_Start

     (Contains Original Data of IP Claims)

     Fields:

     Entity_ID (Long Integer)

     Time_Start (Date/Time)

     Time_End (Date/Time)

     Event_Type (Character)

     Event_State (Long Integer)

VB Module - Output

1. MS Access Results Table

     (Contains Results)

     Master_Entity (Long Integer)

Entity_ID (Long Integer)

Master_Event_State (Long Integer)

State_Count

Duration_Difference

Gap_Difference

VB Module - Pseudo Code

Do Over Entity Table

     Master_Entity = Entity_ID

     Select to RecordSet(A) from Data Table Where Entity_ID = Master_Entity

     Do Over RecordSet(A) * Comment: Loop Through Each Event_State for Master_Entity *

           Master_Event_State = Event_State

           Master_Time_Start = Time_Start

           Master_Time_End = Time_End

           Master_Duration = Time_End – Time_Start

Select to RecordSet(B) from Data Table Where Entity_ID <> Master_Entity and Event_State = Master_Event_State

Do Over RecordSet(B) * Comment: Loop Through All Other (Non Master) Entities with Event_States Matching the Control Event_State of the Master_Entity *

                  State_Count = 1

                  Duration_Difference = Master_Duration – (Time_End – Time_Start)

                  Gap_Difference = Time_Start – Master_Time_Start

Output to Results Table: Master_Entity, Entity_ID, Master_Event_State, State_Count, Duration_Difference, Gap_Difference

End

End

End                  

解决方案

If you don't know where to start, I suggest to start studying the documentation. ADO.Net is the component in the .Net Framework responsible for data access: ADO.Net


这篇关于使用MS访问字段的VB代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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