방법 1 : CreateTableDef 메소드를 사용하십시오
CreateTableFed 메소드는 링크 테이블을 만듭니다. 이 메소드를 사용하려면 새 모듈을 작성한 다음 다음 attachdsnlesstable 함수를 새 모듈에 추가하십시오.
코드 사본은 다음과 같습니다.
'// 이름 : attachdsnlesstable
'// 목적 : createAlinkedTableToSqlServerWithoutUsingAdsn
'// 매개 변수
'// stlocaltablename : thetableThatyourecreating inthecurrentDatabase의 이름
'// stremoTetableName : SQL Server 데이터베이스를 링크하는 thetable의 이름
'// stserver : youarelinkingto의 SQL 서버 이름
'// stdatabase : 연결중인 SQL Server 데이터베이스 이름
'// stusername : SQL Server 사용자의 이름 Whocan SQL Server에 연결, LeaveBlank TouseAtrustedConnection
'// stpassword : sqlserveruserpassword
functionattachdsnlesstable (stlocaltablenameasstring, stremotetablenameasstring, Stserverasstring, Stdatabaseasstring, OptionalStusernameasstring, OptionalStpasswordAsstring)
onerRorgotoattachdsnlesstable_err
DimtDastabledef
DimstConnectAsstring
foreachtdincurrentdb.tabledefs
iftd.name = stlocaltablenamethen
currentdb.tabledefs.deletestLocaltablename
endif
다음
iflen (stusername) = 0then
'// usttrusted authenticationifstusernameisnotsUpplied.
stConnect = "odbc; driver = sqlserver; server ="& stserver & "; database ="& stdatabase & "; trusted_connection = yes"
또 다른
'// 경고 : 이것은 thelinkedtable 정보를 사용하여 Theusername과 ThePassword를 보냅니다.