VB.net Windows Forms application Transfer data from Access to SQL

Hi

I have a Windows forms application where I want my users to transfer Access tables into SQL.
There are several users who don't have SSMS and only app who have to move this data.
I use VB.net code with connection strings to connect to Access via ODBC and SQL using SQLClient
What VB.net code would I use to transfer data from an Access table to a SQL table?
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jacques Bourgeois (James Burger)PresidentCommented:
Have you considered the possibility of using the upgrade Wizard in Access or tools such as the SQL Server Migration Assistant?

Doing it in code could involve a lot of work and many tries, depending on many factors. And you have to explore all these factors before deciding on the most appropriate way to do it.

Are the tables already created in SQL Server or do you need to create them through your application? If they are, do they already contain data, specially data that has primary keys that could come into conflicts with the primary keys in the Access database.

Are you combining individual Access databases in a single instance of SQL Server, individual Access databases in individual instances of SQL Server, data from a unique Access database? How do you want to handle primary keys?

In the first case, you need to see how you are going to handle primary keys that might have the same value for different records in the Access database.

These are but a few of the questions that could influence how you go about it.

One way to go (there are others as well as a lot of variations of each), that would not work in many scenarios is to use a SqlDataAdapter, and set it up with different command objects, linked to different databases/servers.

You first set its SelectCommand property to read the data in Access to create a DataTable.

You then manipulate that DataTable to make changes that could be necessary before moving the data to SQL Server. What could be necessary is often found through trial and error.

Finally, you set the InsertCommand property to save the data in the DataTable in your SQL Server instance.

Because the SelectCommand and the InsertCommand are 2 different SqlCommand object, they can have different connections.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks a lot for the help. Realising this would be messy without SSMA I asked another question to see if I could programmatically use the SSMA from my app
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_28632277.html#a40654322
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.