用update更改记录,cnn执行 execute:SqlStr="select * from "&TabName
set rst=ExecuteSql(SqlStr,MsgText) '返回记录集
......
......
rst.move intCount '----- >定位记录集指针
for i = FfmNo To ColNum - 1
SqlStr = "update " & TabName & " set " & frmDataShow.rst.Fields(i).Name & "='" & TxtModify(i).Text & "' where " & frmDataShow.rst.Fields(i).Name &"='" & frmDataShow.dbfList.TextMatrix(intCount, i + 1) & "'"
Set rst = ExecuteSQL(SqlStr, MsgText)
Next i
frmDataShow.dbfList.Refresh
改成上面这样后,虽然没有错误了,但是记录集没有被更改。
其中的ExecuteSQL函数是在标准模块中这样定义的:
......
cnn.ConnectionString = "Provider=MSDASQL.1;Persist Security
Info=False ;Data Sources=dBASE Files;Initial Catalog=" & PathStr
cnn.Open "Driver={Microsoft dBASE Driver (*.dbf)};" & _
"DriverID=277;" & "Dbq=" & PathStr
If InStr("INSERT,DELETE,UPDATE", UCase$(sTokens(0))) Then '对已存在的表的编辑操作
Debug.Print "test1"
Debug.Print SQL
cnn.Execute SQL
Debug.Print "test2"
Msgstring = sTokens(0) & " query successful"
cnn.Close
Else '对表的打开
rst.CursorLocation = adUseClient
rst.Open SQL, cnn, adOpenDynamic, adLockOptimistic
'rst.MoveLast 'get RecordCount
Set ExecuteSQL = rst
End If
......
debug.print显示的信息: test1
update sample set STATE_PROV='test' where STATE_PROV=''
test1
update sample set ZIP_PST_CD='' where ZIP_PST_CD=''
test1
update sample set COUNTRY='Cyprus' where COUNTRY='Cyprus'
test1
update sample set PHONE='357-6-876708' where PHONE='357-6-876708'
test1
update sample set FRST_CNTCT='1990-04-12' where FRST_CNTCT='1990-04-12'
ormat.' where DESCRIPT='3rd side is in CAV format.'
test1
update sample set STUDIO='MGM/UA' where STUDIO='MGM/UA'
test1
update sample set KIDS='True' where KIDS='True'
从debug看好象是没有执行cnn.execute SQL。也没有错误提示消息。是什么道理呢?
set rst=ExecuteSql(SqlStr,MsgText) '返回记录集
......
......
rst.move intCount '----- >定位记录集指针
for i = FfmNo To ColNum - 1
SqlStr = "update " & TabName & " set " & frmDataShow.rst.Fields(i).Name & "='" & TxtModify(i).Text & "' where " & frmDataShow.rst.Fields(i).Name &"='" & frmDataShow.dbfList.TextMatrix(intCount, i + 1) & "'"
Set rst = ExecuteSQL(SqlStr, MsgText)
Next i
frmDataShow.dbfList.Refresh
改成上面这样后,虽然没有错误了,但是记录集没有被更改。
其中的ExecuteSQL函数是在标准模块中这样定义的:
......
cnn.ConnectionString = "Provider=MSDASQL.1;Persist Security
Info=False ;Data Sources=dBASE Files;Initial Catalog=" & PathStr
cnn.Open "Driver={Microsoft dBASE Driver (*.dbf)};" & _
"DriverID=277;" & "Dbq=" & PathStr
If InStr("INSERT,DELETE,UPDATE", UCase$(sTokens(0))) Then '对已存在的表的编辑操作
Debug.Print "test1"
Debug.Print SQL
cnn.Execute SQL
Debug.Print "test2"
Msgstring = sTokens(0) & " query successful"
cnn.Close
Else '对表的打开
rst.CursorLocation = adUseClient
rst.Open SQL, cnn, adOpenDynamic, adLockOptimistic
'rst.MoveLast 'get RecordCount
Set ExecuteSQL = rst
End If
......
debug.print显示的信息: test1
update sample set STATE_PROV='test' where STATE_PROV=''
test1
update sample set ZIP_PST_CD='' where ZIP_PST_CD=''
test1
update sample set COUNTRY='Cyprus' where COUNTRY='Cyprus'
test1
update sample set PHONE='357-6-876708' where PHONE='357-6-876708'
test1
update sample set FRST_CNTCT='1990-04-12' where FRST_CNTCT='1990-04-12'
ormat.' where DESCRIPT='3rd side is in CAV format.'
test1
update sample set STUDIO='MGM/UA' where STUDIO='MGM/UA'
test1
update sample set KIDS='True' where KIDS='True'
从debug看好象是没有执行cnn.execute SQL。也没有错误提示消息。是什么道理呢?
解决方案 »
- vb listview显示数据库内容
- msflexgrid.mousecol属性获得的列值总是为0?
- VB通信软件轮询4个单片机,高手进来帮忙啊
- 在VB6中,我们通过API函数SHBrowseForFolder和SHGetPathFromIDList创建了“浏览文件夹”窗口。请问如何让“浏览文件夹”窗口记住上一次访
- VB编译成.exe文件时总提示:“该部件的许可信息没有找到。在设计环境中没有合适的许可证使用该功能”,无法编译成.exe文件
- 如何发邮件?
- 如何实现局域网内所有计算机同时操作一个数据库啊,请大家帮忙啊!
- vb调用fortran(字符串传递)
- 数据库的删除问题(DBF库)?????
- 帮个忙,谁能告诉我如何用VB实现解开和打CAB包!(给分,但不多)
- 请问如何用vb按文件块读流媒体文件?
- 我现在有一个特别长的文本要放进Access数据库中(超过memo字段的最大长度),有没有好的办法处理?
'begin
with objAdoCmd
.ActiveConnection = cnn
.CommandType = adCmdText
.CommandText = SQL
.Execute
end with
'end
Debug.Print SQL
cnn.Execute SQL
Debug.Print "test2"
Msgstring = sTokens(0) & " query successful"
cnn.Close
Else '对表的打开
rst.CursorLocation = adUseClient
rst.Open SQL, cnn, adOpenDynamic, adLockOptimistic
'rst.MoveLast 'get RecordCount
Set ExecuteSQL = rst
End If