473,395 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Copy tables from MS access to MSSQL

Hi i am very stuck there.

I am trying to create an vb.net program to transfer or copy tables from my access database to an MSSQL DB.

I got it working to copy from MSSQL to access but not the other way around.

Thanks in advance for helping
Feb 17 '09 #1
7 4666
jg007
283 100+
Please post your example code here and any errors received .

the code to copy from one to the other would probably be pretty much the same for either direction or at least it was when I was using access and MS SQL server
Feb 17 '09 #2
Thanks and sorry should of posted the code first lol


The code is

Expand|Select|Wrap|Line Numbers
  1.                 Dim Cmd As OleDbCommand
  2.                 Dim SQL As String
  3.                 Dim objCmd As New OleDbCommand
  4.                 Dim Con = New OleDbConnection("Provider=SQLOLEDB;" & db_conn_string)
  5.  
  6. SQL = "SELECT * INTO [" & lst_restor_list_confirm.Items(count) & "] FROM [odbc;Driver={Microsoft Access Driver (*.mdb)};Dbq=" & frm_restore_db.OpenFileDialog1.FileName & ";Uid=;Pwd=;].[" & lst_restor_list_confirm.Items(count) & "]"
  7.  
  8. Cmd = New OleDbCommand(Sql, Con)
  9.  
  10. objCmd = New OleDbCommand(SQL, Con)
  11. Con.Open()
  12. objCmd.ExecuteNonQuery()
  13.  
  14. Con.Close()
  15.  
  16.  

and the error i get is


System.Data.OleDb.OleDbException was unhandled

ErrorCode=-2147217865
Message="Invalid object name 'odbc;Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\db_backup_15-02-2009.mdb;Uid=;Pwd=;.tb_user'."
Source="Microsoft OLE DB Provider for SQL Server"

if it helps the sql statment shows as below when the code is running

SELECT * INTO [tb_user] FROM [odbc;Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\db_backup_15-02-2009.mdb;Uid=;Pwd=;].[tb_user]


any help you can give is thanked big time
Feb 17 '09 #3
jg007
283 100+
bit difficult to work out without the database but did you mean to have the connection string and the select statement together like that as it does not seem right
Feb 17 '09 #4
nukefusion
221 Expert 100+
jg007 is right. Your SELECT statement is incorrect. You have your second connection string where the table name should be.
Feb 17 '09 #5
what something like

SELECT * INTO [mssql_database_connecting].[tb_user] FROM [odbc;Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\db_backup_15-02-2009.mdb;Uid=;Pwd=;].[tb_user] somthing like that
Feb 17 '09 #6
nukefusion
221 Expert 100+
No, as far as I know you can't use an SQL statement in that way. You can move things between different databases, say when using a single connection to a single server, but you're trying to move things between two different database types and therefore two different connections.

You'll need to connect to your access database, SELECT out your data into a DataTable object or something. Close the access connection. Open a connection to SQL server, then copy the data from the DataTable object to the SQL database using an INSERT statement.
Feb 17 '09 #7
ok np i give that an go then thanks for your help
Feb 17 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Emille378 | last post by:
Environment is SQL Server 2000 64 bit. I restore from a script 'my' database, this works fine. However, all the tables are also found in master, no data though. Anyone experienced this?
5
by: Kevin | last post by:
Can anyone recommend the easiest way to get a full copy of a database from one server to another. The servers are not part of the same organization or network. I have received a backup of the...
4
by: oceanhai | last post by:
We currently have a PPTP connection set up for our developers to access our development SQL server through a VPN tunnel. When they need to copy tables up to the dev SQL from their local machine...
6
by: Thanks | last post by:
Two Windows 2003 server, one with SQL 2005 server, another with SQL Express. Is it possible to copy databases from SQL 2005 to SQL Express? Thanks.
2
by: raylopez99 | last post by:
I am trying to program a database from inside C++.NET via Visual Studio 2005 using the ADO.NET set of classes, but this I believe is a SQL Server 2005 Express permissions question under Windows XP...
25
by: bubbles | last post by:
Using Access 2003 front-end, with SQL Server 2005 backend. I need to make the front-end application automatically refresh the linked SQL Server tables. New tables will be added dynamically in...
5
ak1dnar
by: ak1dnar | last post by:
Hi, I need to copy some tables from my local MsSQL(2000) database to remote MSSQL server.I think I should use DTS for this purpose. I can Connect to remote server and I cam copy the tables to...
8
by: pechar | last post by:
Hi all, I created an application to copy certain tables from a database on MSSQL server to another database on MYSQL server which is on another server (very very very far away). The process works...
1
by: dwjongbloed | last post by:
We have a third party application that uses an Access front end but the tables in Access are pointed to our MSSQL Server. I have no idea how these are pointed to our server and am looking for any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.