回 帖 发 新 帖 刷新版面

主题:急!一个VB与SQL的问题,请高手进来看一下,这个问题我不知道怎样形容


我想打开一个SQL数据库
Dim xiugan As ADODB.Connection '
        Dim rstxiugan As ADODB.Recordset
        Dim cmmxiugan As ADODB.Command
Set xiugan = New ADODB.Connection '设置连接对象实例
        xiugan.CursorLocation = adUseClient
        '打开数据源连接
        xiugan.Open "provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=shujuku;Data Source=ZHANGHONGYU"
        '设置记录集对象实例
        Set rstxiugan = New ADODB.Recordset
        Set rstxiugan.ActiveConnection = xiugan
        '打来记录集
        rstxiugan.Open "select * from yonghu", xiugan, adOpenStatic, adLockOptimistic
        '设置命令对象实例
        Set cmmxiugan = New ADODB.Command
        Set cmmxiugan.ActiveConnection = xiugan
rstxiugan.Open a, xiugan, adOpenKeyset, adLockOptimistic
我运行时,出现这样的情况
       ”对象打开时,不允许操作
[color=800000]”对象打开时,不允许操作 [/color]

回复列表 (共1个回复)

沙发

Dim xiugan As ADODB.Connection '
        dim xiugai as ADODB.Connection
        Dim rstxiugan As ADODB.Recordset        
Set xiugan = New ADODB.Connection '设置连接对象实例
        xiugan.CursorLocation = adUseClient
        '打开数据源连接
        xiugan.Open "provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=shujuku;Data Source=ZHANGHONGYU"
        '设置记录集对象实例
        Set rstxiugan = New ADODB.Recordset
        Set rstxiugan.ActiveConnection = xiugan
        '打来记录集
        rstxiugan.Open "select * from yonghu", xiugan, adOpenStatic, adLockOptimistic

我来回复

您尚未登录,请登录后再回复。点此登录或注册