与 FoxPro(或其他)表一起操作 oledb 表

发布于 2024-10-27 06:20:02 字数 553 浏览 6 评论 0原文

我正在使用 VB.NET 将大量 FOXPRO/FOXWEB 文件转换为 ASP.NET。底层数据库仍将是 FOXPRO(目前)。

给定两个不同数据库中共享公共字段的两个表。 假设第一个表是“table1”,第二个表是“table2”,公共字段的名称是“cid”

假设我使用 oledb 从 table1 中提取一个名为“interestingrows”的 oledb 表,使用如下代码行:

adapter.Fill(MyDataSet, "interestingrows")

我想说的是

sql = "DELETE FROM interestingrows WHERE cid in (SELECT cid FROM TABLE2)"

......除了sql cmd被发送到我的适配器,它连接到foxpro db并且“interestingrows”是一个oledb表。

如果当我们最终决定将底层数据库切换到 MS SQL(或任何客户决定的数据库)时该解决方案能够发挥作用,那就太好了,尽管不是绝对必要的。

I'm converting a lot of FOXPRO/FOXWEB files to ASP.NET with VB.NET. The underlying database will remain FOXPRO (for now).

Given two tables in two different databases that share a common field.
Say the first table is "table1" and the second is "table2" and the name of the common field is "cid"

Say I have used oledb to extract an oledb table from table1 called "interestingrows" using a line of code something like:

adapter.Fill(MyDataSet, "interestingrows")

I would like to say something like

sql = "DELETE FROM interestingrows WHERE cid in (SELECT cid FROM TABLE2)"

... except the sql cmd is being sent to my adapter which is connect to a foxpro db and "interestingrows" is an oledb table.

It would be very nice, though not absolutely necessary, if the solution will work when we eventually decide to switch underlying database to MS SQL (or whatever customer decides on).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白馒头 2024-11-03 06:20:02

根据您的评论反馈,您可能想要创建一个指向两个表的公共根文件夹的辅助“连接”...否则我预计您的查询将通过尝试从当前连接所在的位置获得上一级的访问权限而失败...这可能会让你失败。因此,使用新的根连接路径,您的查询可以引用一个查询中的路径和表...类似于...

C:\Somewhere\CommonPath\
C:\Somewhere\CommonPath\PrimaryData\
C:\Somewhere\CommonPaht\AlternateData\

并且您当前的连接将

C:\Somewhere\CommonPath\PrimaryData\

创建一个指向的 SECONDARY 连接

C:\Somewhere\CommonPath\

然后您的查询可以类似于

delete from PrimaryData\Table1
   where cid in ( select cid from AlternateData\Table2 );

Based on your comment feedback, you might want to create a SECONDARY "Connection" that points to the common root folder to both tables... Otherwise I expect your query would fail by trying to gain access one level UP from where the current connection is... It might fail you on that. So, with a new rooted connection path, your query can reference the paths and tables in one query... something like...

C:\Somewhere\CommonPath\
C:\Somewhere\CommonPath\PrimaryData\
C:\Somewhere\CommonPaht\AlternateData\

and your current connection is going to

C:\Somewhere\CommonPath\PrimaryData\

create a SECONDARY connection pointing to

C:\Somewhere\CommonPath\

Then your query can be something like

delete from PrimaryData\Table1
   where cid in ( select cid from AlternateData\Table2 );
心如狂蝶 2024-11-03 06:20:02

直接向基础表发出 SQL 命令怎么样?

DELETE FROM Table1 WHERE cid in (SELECT cid FROM Table2)

How about issuing the SQL command directly to the underlying tables?

DELETE FROM Table1 WHERE cid in (SELECT cid FROM Table2)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文