# 便宜你了...

Posted by 安宝 on May 31, 1999 at 15:49:38:

In Reply to: Re: VB与Oracle ... posted by Scott on May 31, 1999 at 14:24:05:

请问如何将Oracle之database连上成Recordset
再进行一般的VB程式处理如:rs.edit/rs.update?

A: 很抱歉 , Oracle 没有 RecordSet 这种东西 , 或许您可以用以下范例:

' Oracle DataBase Object
Public OraSession As Object
Public OraDatabase As Object
Public OraDynaset As Object
Public SQL$
Public MyDyn As Object
Dim UserName as String
Dim Password as String
Dim Connect as String

UserName = {UserID}
Password = {Password}
DatabaseName = {DataBase Alias}
Connect = UserName + "/" + Password
' 下面两行固定
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.DbOpenDatabase(DatabaseName, Connect, 0&)
' 所有对资料库异动方式均透过以下两行方式处理
SQL$ = "select * from {Table Name}"
Set MyDyn = OraDatabase.DbCreateDynaset(SQL$, 0&)
' 如果是透过 Oradc1 显示资料方式 , 任何更新如下
Set ORADC1.Recordset = MyDyn
' 如果要进行 MyDyn (如 rs) 处理 , 资料移动方式如下
MyDyn.MoveFirst
For i = 1 To MyDyn.RecordCount
Data = MyDyn.Fields("{Fields Name}")
MyDyn.MoveNext
Next i
' 如果要增/删/修资料表格处理 , 需完全透过 SQL 指令
SQL$ = "insert/update/delete ..."
OraDatabase.DbExecuteSQL (SQL$)
OraDatabase.DbExecuteSQL ("Commit")
' 这东西点破是一文不值 , 但也让我们伤了一阵子脑筋
' 便宜你了 , 可能我会被人家 @&^#$ ...

Follow Ups:

- 谢谢你 Scott 18:50:53 6/08/99 (1)
  - 哈哈 ! 大家交换心得 , 互助一下啦 ! (无内文) 安宝 09:40:29 6/09/99 (0)