简体   繁体   English

可以在 ODBC 中创建子数据表吗?

[英]It is possible to create an Subdatasheet in ODBC?

Basically, I'm trying to manage a stock warehouse, and what I'm curious about is that it is possible to implement subdatasheet inside the linked table?基本上,我正在尝试管理一个库存仓库,我很好奇的是可以在链接表中实现子数据表吗? I have found multiple of articles regarding to this issue but some prefer another approach while another boldly claimed that it is not worth it due to performance issues.我发现了多篇关于这个问题的文章,但有些人更喜欢另一种方法,而另一些人则大胆地声称由于性能问题不值得。 (Im using MS Access as front end and MSSQL as backend) (我使用 MS Access 作为前端,使用 MSSQL 作为后端)

Can someone clarify if you can able to create a subdatasheet inside the ODBC?有人可以澄清您是否可以在 ODBC 中创建子数据表吗?

While you can set + use sub datasheets on linked Access tables, that feature does NOT work on linked tables to sql server.虽然您可以在链接的 Access 表上设置 + 使用子数据表,但该功能不适用于 sql server 的链接表。

However, what you can do is create a query on the table (NOTE very careful: that is a query on ONE table).但是,您可以做的是在表上创建一个查询(注意非常小心:这是对一张表的查询)。

then on the top most table in the query builder, you CAN define the sub-data sheet.然后在查询构建器的最上面的表上,您可以定义子数据表。

So, create the 2 3 or 4 tables as a simple query before you START setting up the datasheets.因此,在开始设置数据表之前,创建 2 3 或 4 个表作为一个简单的查询。 Note that each query can be just a "*" as the screen shot shows below.请注意,每个查询可以只是一个“*”,如下面的屏幕截图所示。 And in the next level table, you can then also set the sub-data sheet, and so on.而在下一级表中,还可以设置子数据表,等等。

So, just make sure that EACH query is against the ONE table (the linked table).因此,只需确保每个查询都针对 ONE 表(链接表)。

So, each query is based on the one table.因此,每个查询都基于一个表。 You can thus work your way down.因此,您可以按照自己的方式工作。

Once the sub-data sheet is setup (don't and can't use "auto") then you can get each table to expand in the UI below the next table.一旦设置了子数据表(不要也不能使用“自动”),那么您可以让每个表在下一个表下方的 UI 中展开。

So, you thus get a view like this (top most would be tours).因此,您将获得这样的视图(最重要的是游览)。 Then a booking, a group of people to that booking, and so on.然后一个预订,一群人到那个预订,等等。

在此处输入图片说明

So, NO JOINS in the sql.所以,在 sql 中没有 JOINS。 You can't do this on the linked table(s), since the settings are read only.您不能在链接表上执行此操作,因为设置是只读的。 But, create a query on top most table.但是,在最上面的表上创建一个查询。 Just click on "*" for all columns.只需单击所有列的“*”即可。 Now SAVE the table first.现在先保存表格。

when you bring the query up in design mode, you have to choose design, and THEN right click "any place" on the blank query canvas and choose properties.当您在设计模式下提出查询时,您必须选择设计,然后右键单击空白查询画布上的“任何地方”并选择属性。

eg like this:例如像这样:

在此处输入图片说明

So you can't directly do this on the linked tables.所以你不能直接在链接表上这样做。

Each query is one single "base" table.每个查询都是一个单一的“基”表。 Display property sheet as per above, and then set the datasheet as per above.如上显示属性表,然后如上设置数据表。

So yes, you can do this with ODBC data sources in Access, but (unfortantly) you can't use the linked tables to sql server (or Oracle or whatever).所以是的,您可以使用 Access 中的 ODBC 数据源执行此操作,但是(不幸的是)您不能将链接表用于 sql server(或 Oracle 或其他)。 But you can build and save a query (remember to save first, then re-open).但是您可以构建和保存查询(记住先保存,然后重新打开)。 So, a saved query does support datasheets, and they work even for external ODBC data sources.因此,保存的查询确实支持数据表,它们甚至适用于外部 ODBC 数据源。

And the resulting UI above not only takes zero code, but it even allows editing of the data.上面生成的 UI 不仅需要零代码,而且还允许编辑数据。

I can't recommend this UI for end users, but for some prototyping, and a simple quick way to edit relational data without any code?我不能为最终用户推荐这个 UI,但对于一些原型设计,以及一种无需任何代码即可编辑关系数据的简单快速方法? Yes, the above does work.是的,以上确实有效。

You actually never see or even have to write any SQL for this to work.您实际上从未见过甚至不必编写任何 SQL 才能使其工作。

Edit: Ok, follow up: The issue of course is that the above works great.编辑:好的,跟进:当然,问题是上述方法效果很好。 Cool, but kind of the hug without the kiss.很酷,但有点像没有亲吻的拥抱。 The problem of course is now?问题当然是现在? You click on once to highlight the first query (the top most), and then in the ribbon choose under forms a data sheet.单击一次以突出显示第一个查询(最顶部),然后在功能区中选择表单下的数据表。

Poof!噗! Like magic you get a data sheet form, but no "+" to expand!就像魔术一样,您会得到一个数据表表单,但没有“+”来展开!

So, what to do?那么该怎么办? Ok, well, as per above, create the 3 (or however many tables you setup as queries).好的,如上所述,创建 3 个(或您设置为查询的任意多个表)。

Turns out you did not really need to do the 4 querys that way!!!事实证明你真的不需要那样做 4 个查询!!!

My bad, my sorry!我的不好,对不起! You can actualy do this with the linked tables!您实际上可以使用链接表来做到这一点!

How?如何?

Ok, for the first linked table, click on (highlight).好的,对于第一个链接表,单击(突出显示)。 Now from ribbon create a datasheet form.现在从功能区创建一个数据表表单。

Like this:像这样:

在此处输入图片说明

Save the form.保存表格。 Do this for each query.为每个查询执行此操作。 Now the frying pan trick: Back to top most first form.现在煎锅技巧:回到最上面的第一种形式。 Open in design mode.在设计模式下打开。

Now drag + drop from the nav pan the 2nd form (child form) onto the form in design mode.现在将第二个窗体(子窗体)从导航栏中拖放至设计模式中的窗体上。

You get a real nice mess like this:你会得到这样一个非常好的混乱:

在此处输入图片说明

Note VERY careful the property sheet for the sub form.注意子表单的属性表非常小心。 Note the link master/child settings!!!注意链接主/子设置!!!

So, just keep dropping in the forms that way.所以,请继续以这种方式输入表格。

Try it as per above with just two froms.按照上面的方法尝试,只需两个 from。 You find that when you flip back into datasheet mode for above, it will show the "+" and expansion just like it did for the queries.您会发现,当您返回到上面的数据表模式时,它会像查询一样显示“+”和扩展。

NOTE very careful here: You do NOT have to create the 4 queries here.注意这里非常小心:您不必在此处创建 4 个查询。 You can create each form based directly on each base table.您可以直接基于每个基表创建每个表单。 So, this saves the need to create the query for each one.因此,这节省了为每个查询创建查询的需要。 Just create a form for the first linked table.只需为第一个链接表创建一个表单。 Then a form for the 2nd linked table.然后是第二个链接表的表格。

Now open up the first form in desing mode, and drag + drop on the other form.现在以设计模式打开第一个表单,然后在另一个表单上拖放。

Normally sub forms on sub-forms do NOT allow continues form views to be stacked, but datasheet forms are a exception and allow this.通常子窗体上的子窗体不允许堆叠连续窗体视图,但数据表窗体是一个例外并允许这样做。

The results are identical to the stacked queries, and in fact a bit less work, since the forms actually allows you to use the "builder" for the link master and child settings.结果与堆叠查询相同,实际上工作量更少,因为表单实际上允许您将“构建器”用于链接主设置和子设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM