SQL Server:过程 请求失败,因为 是表对象

 

首先import win32com.client #导入com相关的库

使用Python连接SQL Server 2005数据库时出现了以下问题:

rs = win32com.client.Dispatch(r'ADODB.Recordset') 

rs.Open('[sometable]', conn, 1, 3) 

有时候正常

有时候出现异常,提示:过程'sometable' 的请求失败,因为 'sometable' 是 表 对象。

 

按异常说明好像是把sometable当成过程来处理了,可这里是一个表名啊

网上搜索半天,未果

查看ADO帮助文档,发现recordset.Open 有5个参数

recordset.Open Source, ActiveConnection, CursorType, LockType, Options

 

其中第5个参数Options的说明如下:

Optional. A Long value that indicates how the provider should evaluate the Source argument if it represents something other than a Command object, or that the Recordset should be restored from a file where it was previously saved. Can be one or more CommandTypeEnum or ExecuteOptionEnum values, which can be combined with a bitwise OR operator.

大体就是说与Source参数有关,如何解释Source的意思

有如下几个定义

adCmdUnspecified  -1  Does not spec

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值