How do linked tables in MS Access works? - vba

Need few inputs on how Linked tables work in MS Access . previously we have MS Access forms as front end and SQL server as backend and we used ADP project.
But , now our goal is to convert this ADP to linked tables and accdb project.
I have searched a lot over internet for linked tables and could find only few information over it .
I would like to know how it is different from ADP.
I have already created a new ACCDB project and imported all my forms and linked database objects by using linked tables manager
But , when i try to do lookup for a certain table , it does not work , it is showing an exception that table is not found
Can any one share a piece of code to see how to access a linked table from VB .

Linked tables are similar to local tables but their source is not within the local access database. You might
Link an Excel sheet as linked table
MSSQL as linked table
MySQL as linked table (ODBC connection)
and so on..
after linking, the tables become standard table like any other tables in your Access project. Only different would be, the linked tables will be refreshed at every startup (or at a certain ODBC time interval)
You have mentioned ADP and then linked tables in ACCDB, i guess you want to move from an older Access version to a newer one?
From a concept point of view, there shouldn't be any problem. In the background (VBA) you would either use DAO or ADODB (mostly DAO ist simple and handy)
back to your question.
Make sure all of the tables & queries have been imported
Make sure all linked tables have been refreshed.
produce us few more code or screenshot so we can help you

Related

Copying Existing Access forms to a New Database

I am looking to copy few Access forms (from an existing database) to a new empty database and then link them to tables in a backend SQL server.
The forms I wish to copy over are currently linked to few tables in backend SQL server.I need to delink them from the existling tables and link them to new ones in the server.
I tried to import the forms to the new database and then in the design view changed the "record source" field to the source I wanted to link.But it did not work.
I looked up online for resources, but did not get any clear help.
I am a starter with databases and so a not-so-programmatically complicated approach will be appreciated.
Thanks!

SQL linked to Access add more tables

Ok, I am using an Access 2010 database linked to a SQL 2012 backend. All is well. I migrated using the Migration Wizard - this creates the link without using any pre-created ODBC\DSN file etc. This works great as I do not have to deploy any DSN file to users (it is used by 21 users) I have noticed that linked tables have the below in the Properties\Description:
ODBC;DRIVER=SQL Server;SERVER=XXX;Trusted_Connection=Yes;APP=Microsoft Office 2010;DATABASE=XXX;Network=DBMSSOCN;TABLE=dbo.tblCountries
Now my problem is if I create a new table in the SQL backend, how do I link without using ODBC\DSN? How do I link so it behaves the same as when migrated?
I have tried creating a table then using the description from above and changing the table name to no avail. If I do link via ODBC to the SQL backend, link to the new table then change the ODBC to match that above, Access does not let you change the connection string?
So in summary, are you able to link to new tables in SQL server, after you have used the migration wizard to link?
THanks,
Michael
The DSN connection string is actually stored with the linked table. That's why your users can connect to the linked table without needing to set up a DSN connection.
I do very similar work on a daily basis with Microsoft Access connecting to a SQL database server. I have set up ODBC connections on my development machine, which allows me to easily list the tables available on the SQL server databases, and link to them in my Access applications. When linking to the table, I always save the connection string with the table link, so the end users never need the ODBC connection.
In a sense, you can think of your ODBC connection as a template for connecting to the database. As long as you always save the connection string with the linked table, your users won't need the DSN connection to access the database.
There are times when it is appropriate to use a DSN connection, but in my experience, I find it far more practical to just save the full connection string with the linked table and manage the links using the Linked Table Manager.
Hope that helps!
Adam

Swap Database in visual studio from Access to SQL

I have created a windows form project which is based in vb.net in Visual Studio. This form acts as the front end to the database.
I decided this time round to try use the Dataset Designer in Visual Studio and found it convenient. Using the Wizard I linked up the MS Access database to create the Dataset in the project. This then automatically generated all the relevant table adapters, datasets, bindingsources and so on.
Now, the aim is to transition the same Access database to SQL-server.
The Question is whether it is possible to simply swap the Dataset in Visual Studio to from Access to SQL which have the same table names, structure, relations... I tried modifying the connection string in Settings.settings with no success.
This would save me a lot of time from going through each object and updating the datasource to the new SQL database.
You should be able to establish a separate connection to sql server using ado. You can find typical connection strings easily: try http://www.connectionstrings.com/microsoft-ole-db-provider-for-sql-server-sqloledb/ for example. If the tables exist in sql server, you can SELECT from Access and INSERT into SSvr using 2 different connections, 2 sql command objects. If you have trouble with the SQL (which is very possible, I have not done this with Access), create a dataset from the Access SELECT and use that as an intermediate step. If the tables do not exist yet, get the script for CREATE TABLE in Access or in SSMS, and execute that before doing the SELECT/INSERT operation.

How can I copy tables from one SQL Server database to another using Visual Studio 2010 & SQLEXPRESS

I have two *.mdf databases and trying to copy the ASP.NET membership tables from one to the other.
I have tried the data\schema compare tool which I am either not using correctly or it won't find anything to add\update for some reason.
Publish to provider created an sql file with the data and schema. Don't know how I can use it from within VS to pull some tables I need and add to another existing database.
Is there a console or something I can launch a query from for SQL Server Express to copy tables from one of the db's in its DATA directory to another ?
Update: Just used the import/export data wizard. It finally copied all my tables without error but for some reason did not retain the relationship data/foreign keys. The tables that I copied over to the other database did not exist on the database, so no type conflict could arise but it still didn't copy the diagram and relationships.
Is it require to Copy in real time?..i had made code that copy Data from Sqlserver to MySql but it's real time and if you want to copy data not in real time then You Have to Use Migration toolkit.

Using temporary tables to store data from Excel file

I've got a database with information on servers and applications. I also have an Excel file which has some of that information saved in it .
What I'm trying to do is compare the database with the Excel file and output all the results which are present in the DB and not the Excel file, and vice versa.
After some thinking, I decided that it might be best to create temporary tables and save all the data from the Excel file into them, and then do an outer join between the corresponding tables (I'm using SQL Server).
How do I go about doing this without creating models in Rails for them (unless I specifically have to create them)?
Not sure how to use raw SQL in this instance =s
You actually have several choices on how to import the Excel data. If you're looking for a strictly SQL Server solution then you can use a linked server or distributed queries. You can also use DTS/SSIS (depending on your version of SQL Server) for a solution that's external. You could call the SSIS or DTS packages from your own code. Excel also has an OLE DB provider, so if your application uses ADO or otherwise uses OLE DB then you can use that.
All of these methods are explained in a little more detail on Microsoft's website, including some sample code for some of them.