Using ADO/DAO Connection to Download data from SQL Server -
i trying figure out how download using ado/dao connection in access vba contents of table sql server. trying avoid using linked table because db requires password , keep running issues getting not ask login info. there ideas or references me start on matter?
it appears either way you'll need provide sql credentials.
there's more involved without linking table, you'd want recordset source , "target" table iterate over.
targetrs = currentdb.openrecordset("target", dbopentable) dim con new adodb.connection dim sqlstr string con.open _ "provider = sqloledb;" & _ "data source=sqlserver;" & _ "initial catalog=mydb;" & _ "user id=sa;" & _ "password=p@ssw0rd;" dim rssource new adodb.recordset rssource.open "select * source", con until rssource.eof targetrs.addnew each field in rssource targetrs.fields(field.name) = rssource.fields(field.name) next targetrs.update rssource.movenext loop
since still have have credentials, dynamically link table instead:
docmd.transferdatabase aclink,"odbc database", "odbc;driver={sql server};server=mysqlserver;database=mysqldb; uid=user;pwd=password",actable,"sqltable","myaccesstable"
Comments
Post a Comment