我的模块源代码是:
Option Explicit
Public objRS As Recordset
Public objCn As New ADODB.Connection
Public txtSQL As String '保存SQL语句
Public UserName As String '获取用户输入的用户名
Public deleteID As String
Public Sub subInitDataBase(ByVal strSQL As String)
Set objCn = New Connection '实例化Connection对象objCn
With objCn '建立数据库连接
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;pwd=;Data Source=(local);" & _
"Initial Catalog=教务管理信息系统"
.Open
End With
Set objRS = New Recordset '创建客户端的记录集
With objRS
.CursorLocation = adUseClient '指定使用客户端光标
.CursorType = adOpenStatic '指定使用静态光标
.Open strSQL, objCn
Set .ActiveConnection = Nothing
End With
End Sub
测试时,出现"用户‘sa'登陆失败,原因:未与信任SQL server连接相关联。"这个错误提示~
请各位大虾帮忙~