MS访问中的链接表查询 [英] Link table Query in MS access

查看:99
本文介绍了MS访问中的链接表查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有两个数据库MS Access和DB2,两个都有很多表.在一种情况下,我需要从两个表中获取记录(一个表属于db2,另一个表来自MS Access)我已经在MS Access中创建了DB2表的链接(即-在MS Access视图中,我们可以看到链接的db2桌子).

现在我要运行两个表的查询,我的查询将是这样,
从table1,table2中选择table1.col1,table2.col2,其中(db2)table1.column1 =(MS访问)table2.column1.

对于每个数据库,我也有两个不同的连接字符串.

DB2-连接字符串具有一些用户名和密码.
女士访问权限-也有自己的连接字符串.

我曾使用Ms访问数据库连接字符串,并使用过ODBCCommand(),当我尝试在.net应用程序中执行查询时,它提示我输入DB2用户名和密码.

如何获得上述查询的结果.....?

谢谢
Mani


i have two databases MS access and DB2, both have many tables. In a scenario i need to fetch the record from two tables(one table belongs to db2 and other one is from MS access) I have created the Link for DB2 table in MS Access(i.e - In MS access view we can see the db2 linked table).

Now i want to run the query for two tables,My query will be like this,
"select table1.col1,table2.col2 from table1 , table2 where (db2)table1.column1 = (MS access)table2.column1.

i have two different connection strings as well for each databases.

DB2 - connection string has some userid and password.
Ms access - also has its own connection strings.

I have used Ms access database connection strings, and used ODBCCommand(), when i try to execute my query in .net application it prompted me with DB2 user name and password.

how to get the result for the above query.....?

Thanks
Mani

推荐答案

在Access中创建链接时,尝试将表的DB2用户名和密码保存起来
Did you try saving he DB2 user name and password with the table, when you created the link in Access


没有做一些VB编码就没有简单的方法.基本上,您可以不使用用户标识密码来保存DB2表链接.

然后,在执行查询之前,您需要从vba代码中打开此表def对象并设置链接选项,其中将包括用户ID密码,您可能已经从用户使用表单或其他内容提示了该密码.然后修改tabledef,然后执行查询.这样一来,您无需保存密码即可继续访问并进行本地联接.

看看VBA中的Table Def对象.

希望这可以帮助. Thx
there is no easy way of doing this without doing some VB coding. Basically you can save DB2 table link without the userid password.

Then before u execute the query, from vba code you need open this table def object and setup the link options which will include userid password which u might have prompted from the user using a form or something. Then modify the tabledef and then execute the query. That will allow u not to save the password but still access and make local joins.

Take a look at Table Def objects in VBA.

Hope this helps. Thx


这篇关于MS访问中的链接表查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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