Joinning SQL Server table with *.mdb file - ms-access

I'm trying to joinning SQLServer 2008 R2 tables with msaccess table (*.mdb).
I already tried "OPENDATASOURCE" and "Linked Server", but no one of them is work correctly.
in example, I've got the following message:
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server
"TestLinkServer" returned message "Cannot open database ''. It may
not be a database that your application recognizes, or the file may be
corrupt.".
the other error message:
OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "MDBTest"
returned message "The Microsoft Jet database engine cannot open the
file '\10.55.56.34\Shared Folder\LBUS.mdb'. It is already opened
exclusively by another user, or you need permission to view its
data.".
and many more :D
can anyone give the working tutorial?
thanks in advance.. :)

The easiest way is to do the join inside ms-access.
Set up a table link in your access database that references the sql-server table you want to join.
Then build a query in access that joins that table with one or more tables in the access database.
If you want to join more than one sql-server table, first create a view in sql-server that combines all the relevant tables. Then set up your table link to reference the view.
If, for some reason, you must do the join inside SQL server, you will have to use a different technique, or use the table link feature to "push" data from the access table to a (previously defined) sql server table. Then, it's just an ordinary join.

Related

What's an alternative to triggers when using a Jet tables in an Access Database (mdb file)?

I have this project that would require users to check in/out through a finger print reader ZK SF200.
The system that I am building needs to fetch new data that is added into this machine's database which unfortunately is a MS Access mdb file.
In my limited experience in MS Access databases, I managed to link this file to my MySql database table which allows me to manually do the insert from MS Access.
All I want to do now is to create some form of trigger that would add data to my MySql database when new rows are inserted into the MS Access table.
This problem would have been solved if the file type was .accdb because we can use After Insert events however it is an mbd type so those are not supported.
Any idea on how I can solve this matter ?
As a final note: I am willing to change DBMS in case MySql is the obstacle here. Would creating a linked server or doing sql server replication through mssql 2008 r2 work ?
EDIT: I need to insert data to MySql table because I have a trigger implemented there which does its side of logical manipulation of the data (ex: Increment the number of visits for the customer, check if customer subscription has expired or not and update the customer status accordingly)
Thank you.
Linking a table in MS-Access to the ODBC source is probably an answer for you. The table in MS-Access will be more like a view on the source table. Any DML operation (INSERT, UPDATE, DELETE) will be synced immediately with the source database. You will not need any trigger, which is not available in MS-Access (unless some VBA expert knows a solution).
The Linked table technology is default available for SQL-server, but since it uses ODBC I quess you can use it with MySQL too.

Dreamfactory Cannot Insert Rows Into SQL Server 2008 R2

Can connect and GET data from MS SQL Server from Dreamfactory.
Using dblib (library/driver)
When I try to use the createRecords method, I get a strange error.
If I try to insert records into a table called "iyer_test", I get an error that says table "EMP_OnRolls" does not exist in database.
Why do you think DSP should report an unrelated table as non-existent?
I am trying all this from the Swagger UI - so authentication, session and all other prerequisites are hopefully taken care of.
Service definition : Database Driver : dblib:host=del-xxxxxxxx:1433;dbname=utilities
I can connect to the database server with the user name supplied and the user has rights to read/write/modify rows in the tables. Confirmed with SQL Server Management Studio.
In the Swagger UI, if I enter the table name as "dbo.iyer_temp" I get an error that says dbo.iyer_temp table does not exist.
The body I pass to the createRecord method is {
"record": [ {
"lname" : "Iyer",
"fname" : "K Y
}]
}
The table iyer_temp has an id column called "id".
Why should the DSP report a strange table as not available?
Thanks in anticipation
Best wishes
Iyer
Current versions of the database service attempt to pull other schema from other tables that are viewable given the accessed credentials to determine relationships between tables (note, an upcoming release due out in the next week or so is smarter about what data is pulled). If you list tables available using the getResources() or getTables() method, does that table show up in the list?
If so, that is what is going on, the service is trying to pull schema from that table to determine if they are related. Is there a reason why that table is accessible for retrieving table names but not for schema?
Mark of Dreamfactory mentioned that the php5-sybase driver probably has a problem with MS SQL Server tables with hyphens in the table name.
After removing hyphens from the table name, inserts have worked fine.
Thanks
Iyer

Settting up a SSMS Linked Server to DB2

I have a local SQL Server instance on which I created a Linked Server connection to a DB2 database named "DB2OurDatabase." In creating the Linked Server connection, I specified a UID and PWD that I use in various query tools or applications to query "[SchemaX].[TableX]."
I seemed to have success in creating the Linked Server: A Linked Server node Object by the name of "DB2OurDatabase" was created under the Linked Server node in SSMS and when I expand it, I am able to see the of tables in the database.
When I right mouse click on the [SchemaX].[TableX] table and select
"Script Table as => Select To ==> New Window", a new query window was opened with the text
--[DB2OurDatabase].[DataCenterCityName2_DB2OurDatabase].[SchemaX].[TableX]
contains no columns that can be selected or the current user does not have permissions on that object.
GO
I don't understand how I was able to create a Linked Server that can see the table names in the database but yet apparently seem to encounter what appears to be a lack of rights to query the table even tghough I am using same credentials that I have used in Squirell SQL query tool, for example, to query the table.
In SSMS, I tried to execute this
SELECT *
FROM [DB2OurDatabase].[DataCenterCityName2_DB2OurDatabase].[SchemaX].[TableX]
Error:
Msg 7314, Level 16, State 1, Line 1
The OLE DB provider "IBMDADB2" for linked server "DB2OurDatabase]" does not contain the table ""DataCenterCityName2_DB2OurDatabase"."SchemaX"."TableX"". The table either does not exist or the current user does not have permissions on that table.
I was a little surprised that the fully qualified table name included [DataCenterCityName2_DB2OurDatabase] since I did not specify this when I set up the Linked Server connection, but the name of the DataCenter city was correct so I took this as a further sign that the Linked Server connection was successful.
Nevertheless, I also tried to execute remove this level of the fully qualified table name:
SELECT *
FROM [DB2OurDatabase].[SchemaX].[TableX]
which resulted in this error.
Msg 208, Level 16, State 1, Line 1
Invalid object name 'DB2OurDatabase.[SchemaX].[TableX]'.
What do I need to do to create a DB2 Linked Server that lets me query the tables in the DB2 database? Here's my linked server properties:
I haven't investigate what are probably multiple ways to conenct and query DB2 from Sql Server, but this worked:
SELECT * FROM OPENQUERY(DB2OurDatabase, 'SELECT * FROM SchemaX.TableX')
Obviously, you modified the actual commands by replacing object names, so it's impossible to be sure, but the problem may be caused by your use of quoted identifiers (those square brackets), which essentially makes the object names case-sensitive. DB2 will by default create object (table, schema) names in uppercase, unless they are quoted. create table MySchema.MyTable... (unquoted) on the DB2 side will create the table MYSCHEMA.MYTABLE, and referencing it later from SSMS as [MySchema].[MyTable] (using quoted identifiers) will obviously fail.
These are the 3 steps that bring me to the solution:
Download and install Microsoft OLE DB Provider for DB2 Version 6.0 (this is the latest version but by the time you read this post there might be a new version now)
From the start menu open the Data Access Tool > File > New Data Source and complete all the steps: provide the notorious credentials like Server, Port, Database, User, Password. If unsure contact your DBA. Once completed test the connection and copy the Connection String
Now on SSMS go to Server Object > Linked Servers > New Linked Server and fill up like in picture setting up in the Provider string the string you copied before from the Data Access Tool:
Done, you are good to go now,

How to retrieve the odbc database name of tables in ms-access VBA

I have a ms-access database and several ODBC linked tables in it.
As I have 2 set of ODBC database ,one is for production the other is for development, they have different names Development and Production.
How can I get the odbc info of the linked tables by using VBA?
Using the local name of the table, you can query the MSysObjects system table (typically hidden) for the table's Foreign Name.
SELECT MSysObjects.ForeignName
FROM MSysObjects
WHERE (((MSysObjects.Name)="LocalTableName"));
If you need more information about the foreign table, try your hand at parsing the 'Connect' column from the same table.
In fact, you can use ODBC to connect to the .mdb file as if it were an Access database. The linked tables will show up in that ODBC connection and be accessible at full ODBC speeds.
The nice thing about doing it that way is your program doesn't even have to know if the tables are linked tables or not. It's nice to contain all these sysadmin-level details in a single place.
My usual method of determining the source is to rename the tables, just like you would a native table. I may add a suffix or prefix such as tblTrombone_DEV and tblTrombone_PROD.

MS-Access Add Additional Linked Tables

I have an MS-Access database that was converted to use SQL Tables using the "Microsoft SQL Server Migration Assistant 2008 for Access" (aka SSMA) and created linked tables (so the MS-Access interface still works but is linked to SQL Tables).
Modifying those tables has been no problem (modify in SQL, use the Linked Table Manager in MS-Access, update tables). But I've not added a new table in SQL and I can't find a way to add that table to the set of linked tables.
I've tried the External Data -> ODBC Database, but it wants me to make a FileDSN and since the SSMA tool didn't require that I don't want to have some tables linked one way and other files liked another way (does anyone know how SSMA links the tables?).
So my underlying question is: Without using DSN how do I add an additional SQL Server table to MS-Access as a linked table?