cnn1.Open "........",1,3; ; ; rst_test.update rst_test.Close Set rst_test = Nothing
Set rst_test= New ADODB.Recordset rst_test.CursorLocation = adUseClient rst_test.Open "........", , adOpenStatic, adLockOptimistic, adCmdText; ; ; If rst_test.EOF = False Then '记录不存在,为了生成新记录:产生chworkid rst_test.AddNew rst_test!plan = "0" ...... End Ifrst_test.updaterst_test.Close Set rst_test = Nothing
这样写应该可以 dim rs as new recordset dim conn as new Connection ...... ...... conn.open rs.CursorLocation = adUseClient rs.CursorType = adOpenDynamic rs.LockType = adLockOptimistic rs.Open "select * from ... where ......", conn, , , adCmdText Do Until rs.EOF '此处不知道你地要求是想得到纪录还是。 rst_test.MoveFirst rst_test!plan = "0" loop rs.update rst_test.Close Set rst_test = Nothing
;
;
rst_test.update
rst_test.Close
Set rst_test = Nothing
rst_test.CursorLocation = adUseClient
rst_test.Open "........", , adOpenStatic, adLockOptimistic, adCmdText;
;
;
If rst_test.EOF = False Then '记录不存在,为了生成新记录:产生chworkid rst_test.AddNew
rst_test!plan = "0"
......
End Ifrst_test.updaterst_test.Close
Set rst_test = Nothing
dim rs as new recordset
dim conn as new Connection
......
......
conn.open
rs.CursorLocation = adUseClient
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.Open "select * from ... where ......", conn, , , adCmdText
Do Until rs.EOF '此处不知道你地要求是想得到纪录还是。
rst_test.MoveFirst
rst_test!plan = "0"
loop
rs.update
rst_test.Close
Set rst_test = Nothing
这句话,我执行时出错了,cnn1是连接,后面的参数1和3是什么意思啊.我加参数的时候,看到是userid和password呀.
…………
……
……
rst_test.update
BLOB类型的字段除外
cn6000.Open "Provider=MSDASQL.1;Password=111;Persist Security Info=True;User ID=sa;Data Source=sybase_ju;charset=iso_1"因为我可以读出rst_test中每一个字段的值,但是,我无法更改.无法给它赋值.
我的目的很简单.就是从数据库中查找,如果没有SQL指定的记录,就用addnew增加,这没问题.问题在于,如果有记录,那么记录已读到recordset中了,我怎么更改读出的值,能直接给recordset赋值吗?
rst.fields("字段名").value=值
rst.update
rst.close