domino 连接 sql server 2005 报错,请问是什么原因?
domino 连接 sql server 2005 报错,错误行(Connect.Open ConnectionString)后台提示信息:
2011/08/24 13:22:15 HTTP Server: Agent message: Got error Microsoft OLE DB Provider for ODBC Drivers: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. on line 31
2011/08/24 13:22:15 HTTP Server: Agent 'GetKaoqinInfoFromSQL|抓取本地考勤信息从SQL服务器' error: No RESUME
代码如下:
Option Public
Option Declare
UseLSX "*lsxodbc"
Use "commonfunction"
Dim CF As Commonfunction
Sub Initialize()
On Error GoTo errorhandle
Dim s As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim tempdoc As NotesDocument
Dim doc As NotesDocument
Set CF=New commonFunction
MsgBox "in"
'定义ADO对象变量,供SQL用
Dim Connect As Variant
Dim ADOCommand As Variant
Dim RecordSet As Variant
Set Connect = CreateObject( "ADODB.Connection" ) '创建ADO连接对象
Set Recordset = CreateObject( "ADODB.Recordset" ) '创建返回结果集对象
Dim SQLSERVER As string '取得SQL服务器的IP地址
Dim SQLDB As String '要连接的SQL库
Dim SQLUID As String 'SQL用户名
Dim SQLPWD As string 'SQL密码
Dim ConnectionString As string
SQLSERVER = "192.168.40.12"
SQLDB = "kaoqin2011"
SQLUID = "sa"
SQLPWD = "sa"
ConnectionString = |Driver={SQL SERVER};SERVER=| + SQLSERVER + |;DATABASE=| + SQLDB + |;UID=| + SQLUID + |;PWD=| + SQLPWD + |;|
Connect.Open ConnectionString '创建SQL连接
If Connect.State = 1 Then
MsgBox "连接成功"
Else
MsgBox "连接不成功"
End If
Exit Sub
errorhandle:
'MsgBox "The error happend in line :"+CStr(Erl)
MsgBox "Got error " & Error$ & " on line " & CStr(Erl)
End Sub
function FormatIDStr(IDStr As String ,TCStr As String,Num As Integer) As string
Dim IDStrLen ,i As Integer
Dim tempstr As String
tempstr=IDStr
IDStrLen=Len(IDStr)
If IDStrLen<Num Then
For i=1 To Num-IDStrLen
tempstr=TCStr+tempstr
Next
End If
FormatIDStr=tempstr
End function
请各位看看到底是什么原因?
谢谢! --------------------编程问答-------------------- 你用SQL CLIENT连接看一下能不能连上,报错信息提示,数据库不存在,或是连接错误
--------------------编程问答-------------------- 检查服务器上有配置sqlserver数据源没 --------------------编程问答-------------------- SQL CLIENT 连接?
能说清楚些吗?感谢了!
--------------------编程问答-------------------- domino 服务器和sql server 2005 都按装在同一台服务器; --------------------编程问答--------------------
是根据数据源配置中获取数据库链接的,管理工具——>数据源(ODBC) --------------------编程问答--------------------
就是sql server management studio --------------------编程问答-------------------- 好久不见有人用ADO了。
貌似用ODBC的更多些。 --------------------编程问答-------------------- 请确定是否设置的是系统数据源 --------------------编程问答-------------------- 是不是缺少了实例名称?应该是SQLSERVER = "192.168.40.12/XXXXX" XXXX为SQL Server 2005实例名称,具体你看一下SQL Server 2005管理连接器里面是怎么连你那个考勤DB kaoqin2011的, --------------------编程问答-------------------- 用ADO方法吧 不用配置ODBC的 --------------------编程问答-------------------- 首先确定代理是本地执行还是在服务器执行,如果在本地执行就需要再本地配odbc,如果在服务器执行就要在服务器配置 --------------------编程问答-------------------- 一般都不这样连接,通常都是采用“数据源”的方式连接(ODBC). --------------------编程问答-------------------- ConnectionString = |Provider={SQLOLEDB.1};SERVER=| + SQLSERVER + |;DATABASE=| + SQLDB + |;UID=| + SQLUID + |;PWD=| + SQLPWD + |;|
驱动看看改一下试试。 --------------------编程问答-------------------- 用ado不用配置odbc!直接在代码里写连接语句,包括可以访问sql的用户名,密码,服务器地址和数据库名,表名 --------------------编程问答-------------------- 这是我用的连接,你试试看
Dim Conn As Variant
Dim EmpRS As Variant
Dim DBConStr As String
Dim SQLCmd As String
Dim NewUser As Variant
Dim tempstr As String,tempstr1 As String
Dim time1 As String,time2 As String
'ADO Constants
Const adStateOpen = 1
Const adCmdText = 1
Const adOpenStatic = 3
Const adLockOptimistic = 3
'Connection String (Use DSN-Less connection string)
DBConStr = "Provider=SQLOLEDB.1;Persist Security Info=True" & _
";Data Source=192.168.10.110;User Id=sa;Password=weijia3624<>;Connect Timeout = 10;" & _
"Initial Catalog=hrms_db_20091214;"
'Create and Open Connection Object
Set Conn = CreateObject("ADODB.Connection")
Conn.Open DBConStr --------------------编程问答-------------------- 我也是用ADO的,还是很方便的么
补充:企业软件 , Lotus