PC Review


Reply
Thread Tools Rate Thread

How to copy an Access database using ADO.NET and C#???

 
 
Jon S via DotNetMonster.com
Guest
Posts: n/a
 
      18th Nov 2005
Hi all,

I have an Access '97 database called "dbHLS", inside this database I have a
table called "tbHLS". I would like to copy the table tbHLS from within the
dbHLS.mdb to an Access 2002 database called "dbTarget". Obviously as I'm
copying the table tbHLS I dont want anything to do with the table to change
other than the location of it.

Can this be done? if so how can it be done?? Anyone know of any links???

Thanks in advance.

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...o-net/200511/1
 
Reply With Quote
 
 
 
 
Paul Clement
Guest
Posts: n/a
 
      18th Nov 2005
On Fri, 18 Nov 2005 16:54:31 GMT, "Jon S via DotNetMonster.com" <u2272@uwe> wrote:

¤ Hi all,
¤
¤ I have an Access '97 database called "dbHLS", inside this database I have a
¤ table called "tbHLS". I would like to copy the table tbHLS from within the
¤ dbHLS.mdb to an Access 2002 database called "dbTarget". Obviously as I'm
¤ copying the table tbHLS I dont want anything to do with the table to change
¤ other than the location of it.
¤
¤ Can this be done? if so how can it be done?? Anyone know of any links???

The following code will create the table and copy the data. However, it will not create any indexes
or primary keys, etc.

Function ExportAccessToAccess() As Boolean

Dim AccessConn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"
& _
"Data Source=e:\My Documents\dbHLS.mdb")

AccessConn.Open()

Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [MS
Access;DATABASE=E:\My Documents\dbTarget.mdb;].[tbHLS] FROM tbHLS", AccessConn)

AccessCommand.ExecuteNonQuery()
AccessConn.Close()


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy an entire database and paste to new database in Access 2003 Chrystela Microsoft Access External Data 5 4th Jan 2008 07:12 PM
Re: copy access database Larry Linson Microsoft Access VBA Modules 0 16th Jan 2007 03:55 AM
How to copy bulk copy MS Access queries from one database to another Ron Carr Microsoft Access Queries 4 27th Dec 2005 05:25 PM
Access Database Copy =?Utf-8?B?Um9iYmlu?= Microsoft Access Database Table Design 0 5th Jul 2005 11:53 PM
Copy access database =?Utf-8?B?QW1kdWtl?= Microsoft Access 3 21st Apr 2005 05:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:06 AM.