Export Data from SQL Server to Access without DTS via .NET

J

Jason

I want to export up to a million rows from an SQL Server table (2000 Server
on Win2003 Server) to an Access 2003 table via a VB.NET program running on
Windows XP. I don't want to use DTS. I would optimally like to use Bulk
Insert commands or something like that. I can figure out how to get it out
of SQL Server pretty easily perusing BOL, but I'm not sure how to then get
it into Access. Does anyone have a fast and easy way to accomplish this?
Thanks!
 
G

Guest

Jason,

One idea that I can think of is export the data from sql to a specified
location then grab the MS Access database and use the docmd.transferdatabase
command within Access. I have posted a couple of links below to aid you if
you choose to explore this idea.

Hope this helps.
 
P

Paul Clement

¤ I want to export up to a million rows from an SQL Server table (2000 Server
¤ on Win2003 Server) to an Access 2003 table via a VB.NET program running on
¤ Windows XP. I don't want to use DTS. I would optimally like to use Bulk
¤ Insert commands or something like that. I can figure out how to get it out
¤ of SQL Server pretty easily perusing BOL, but I'm not sure how to then get
¤ it into Access. Does anyone have a fast and easy way to accomplish this?
¤ Thanks!
¤

Not sure whether you are working with an existing Access table but the following uses SQL to import
into a new table:

Function ImportSQLServerToAccess() As Boolean

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

AccessConn.Open()

Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO Orders FROM [Orders]
IN '' [ODBC;Driver={SQL Server};Server=(local);Database=Northwind;Trusted_Connection=yes];",
AccessConn)

AccessCommand.ExecuteNonQuery()
AccessConn.Close()

End Function


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top