这个问题是由Sybase ODBC驱动的bug引起的,官方文档记述如下:
- 342554: ODBC: E_FAIL status with AddNew() and CursorLocation set
to adUseClient in a Visual Basic ADO applciation. This is resolved
by using the WorkArounds2=16 connection attribute. You can add this
to the ADO connections string as "WA2=16". Another alternative is
to add the "WorkArounds2=16" for the DSN as found in the registry
under ODBC.INI.
解决方法也就如上面记述的一样:
- 方法一
- 创建连接的时候添加"WA2=16"参数,例子如下:
- Dim cnn As ADODB.Connection
- Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
cnn.CursorLocation = adUseClient
cnn.Open ("DSN=jomosybase;UID=JOMOVB;PWD=123456;WA2=16")
用此连接创建的RecordSet和控件绑定进行数据更新操作可以正确执行。
- 方法二
- 在注册表中搜索:"ODBC.INI",找到Sybase对应的数据源,在该数据源下面添加一个文字列
键:WorkArounds2
值:16