export database table
can some one tell me how do i export a table in sql server to microsoft access, using vb6? :confused:
Thanks! :)
[122 byte] By [
blurblur] at [2007-11-11 10:12:07]

# 1 Re: export database table
Here's one way to do it:
Dim cn As ADODB.Connection
Dim SQL As String
Set cn = New Connection
cn.Open "Provider=SQLOLEDB;User ID=<username>;Password=<password>;Initial Catalog=<database>;Data Source=<servername>"
SQL = "INSERT OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source=""d:\path\access_db_name.mdb"";')...<desttable>" & _
"SELECT * FROM <sourcetable>"
cn.Execute SQL
cn.Close
Replace the tokens between angle brackets with the appropriate values.
# 2 Re: export database table
Below is another method:
Dim cnn As New ADODB.Connection
Dim strSQL As String
cnn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=d:\My Documents\db1.mdb;" & _
"Jet OLEDB:Engine Type=4;"
strSQL = "SELECT * INTO [Customers] FROM Customers IN '' [ODBC;Driver={SQL Server};Server=(local);Database=Northwind;Trusted_Connection=yes];"
cnn.Execute strSQL
cnn.Close
Set cnn = Nothing