Sometimes we want to obtain part of the data in the SQL database, while the other part of the data in the access database, but sometimes we need to associate the data in the two databases for query, integrating them into a dataset is undoubtedly a good method. follow the steps below to Access SQL data only when SQL is connected to database statements.
Sometimes we want to obtain part of the data in the SQL database, while the other part of the data in the access database, but sometimes we need to associate the data in the two databases for query, integrating them into a dataset is undoubtedly a good method. follow the following steps to perform a joint query of SQL data and access data when only SQL statements are connected to the database.
First, you need to use an account with database administrator permissions to execute the following script 01_AddLinkServer. SQL, and the content of 01_AddLinkServer. SQL is as follows:
Use master
EXEC sp_addmediaserver
@ Server = 'valinkmdb ',
@ Srvproduct = '',
@ Provider = 'Microsoft. Jet. OLEDB.4.0 ',
@ Datasrc = 'C: \ McMo. mdb'
GO
EXEC sp_add1_srvlogin
@ Rmtsrvname = 'valinkmdb ',
@ Useself = 'false'
GO
VALINKMDB is a simulated access Database. check enterprenterprenterprenterprenterprenterprenterprenterprenterprenterprenterprenterprenterprenterprenterpr- link to the server> project,
Make sure that the entry of VALINKMDB is created. Then you can directly query the data in the aceess database on the SQL query analyzer, such as: select * from VALINKMDB... test: the name of the table you want to query in the access database. of course, you can perform a joint query at this time, for example: select * from VALINKMDB... test inner join sqldatabase on sqldatabase. number = test. number
You can apply it in asp,. net, or other languages.
If you have any questions, contact us.