Office中国论坛/Access中国论坛

标题: Access链接SQL SERVER数据库表的求助 [打印本页]

作者: wdelin    时间: 2008-3-15 19:39
标题: Access链接SQL SERVER数据库表的求助
ACCESS希望通过代码实现创建链接SQL SERVER数据库SYNTHSIS中的表dbo.r1员工登记表(mysql是ODBC数据源):
Dim adoConnection As New ADODB.Connection
Dim adoCatalog As New ADOX.Catalog
Set adoCatalog = New ADOX.Catalog
Set adoCatalog.ActiveConnection = CurrentProject.Connection
Dim adoTable As New ADOX.Table
Set adoTable.ParentCatalog = adoCatalog

adoTable.Properties.Item("Jet OLEDB:Remote Table Name").Value = "dbo.r1员工登记表"
adoTable.Properties.Item("Jet OLEDBink Provider String").Value = "Description=mysql;DRIVER=SQL Server;SERVER=SYNTHSIS;APP=Microsoft Office 2003;WSID=SYNTHSIS;DATABASE=dbpersonnelSQL;Trusted_Connection=Yes"
adoTable.Properties.Item(8).Value = True
adoTable.Name = "dbo_r1员工登记表"
adoCatalog.Tables.Append adoTable
            
Set adoTable = Nothing
Set adocatlog = Nothing
无法创建新的链接表dbo.r1员工登记表(用手工方式可以创建),错误信息为"找不到可安装的ISAM".

请教怎么办才好?

[ 本帖最后由 wdelin 于 2008-3-15 19:57 编辑 ]
作者: Grant    时间: 2008-3-15 19:44
ADO链接SQL SERVER的函数.
Public Conn As New ADODB.Connection
Public Function ConnectToServerSQL(ServerName As String, DatabaseName As String, uID As String, Optional Pwd As String = "") As Boolean  
On Error GoTo Err  
If Conn.State <> adStateClosed Then
Conn.Close  
Conn.C & Pwd & "ersist Security Info=True;User ID=" & uID & ";Initial Catalog=" & DatabaseName & ";Data Source=" & ServerName  
Conn.CursorLocation = adUseClient  
Conn.ConnectionTimeout = 60  
Conn.CommandTimeout = 600  
Conn.Open  
ConnectToServerSQL = True  
Exit Function
Err:
ConnectToServerSQL = False
End Function
作者: Grant    时间: 2008-3-15 19:45
王站什么时候调整一下表情符号~一发代码不是冒汗就是在笑
作者: wdelin    时间: 2008-3-17 09:34
我是正在学习的新手,一个问题就是一只拦路虎,非常诚挚地感谢你的帮助,Grant!




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3