我正在使用一个多值数据库,该数据库目前正在使用 IBM U2(现为 Rocket Software)的 UniObjects 软件连接到 Universe 9.+ 系统。这不是 Rocket Software 为 Universe 10+ 和 11+ 系统推出的 UniObjects for .NET。我必须用来尝试连接到 Universe 9+ 系统的唯一示例是使用 Visual Basic 6.0,我需要使用 C#。谁能告诉我如何在 C# 中连接到 Universe 9+ 系统?基本上,我正在尝试将我在 VB 6 中使用的内容转换为 C#,以便连接到该系统。感谢您提供的所有帮助。文档中的一些示例如下:
Sub SampleFile ()
' SampleFile
'
' This routine creates a new session and opens the chosen
account's VOC
' file. The user is asked for a record id from VOC (e.g.
RELLEVEL), which
' is read and displayed in a message box. Finally the session
is closed.
Dim objSession As object ' The Session to the database
Dim objFile As object ' The file to open (VOC)
Const UVE_NOERROR = 0 ' From UVOAIF.TXT - no error
' The registered name of a database Session - Version 1
Const UV_SESSION_OBJECT = "UniObjects.unioaifctrl"
'
' Create a Session object to work with
' - This is a contrived sample, in a full application the
session object
' - would typically be a Global variable that is set once
maybe in
' - response to a menu selection (e.g. Connect) on the main
form.
'
Set objSession = CreateObject(UV_SESSION_OBJECT)
If objSession Is Nothing Then
' NB. Errors will be reported by VB
Exit Sub ' End the program
End If
objSession.UserName = Input.Box ("User Name:","Login")
objSession.Password = Input.Box ("Password:","Password")
'
' Establish a connection to the database server. By default it
displays
' a dialog box to request the HostName and AccountPath property
values.
'
objSession.Connect
If objSession.IsActive Then
'
' Open the VOC file
'
Set objFile = objSession.OpenFile("VOC")
If objFile Is Nothing Then
MsgBox "Unable to open VOC file (" & objSession.Error &
")"
Exit Sub ' End the program
End If
'
' Read user entered record from the VOC e.g. RELLEVEL
'
objFile.RecordId = InputBox("Enter Record Id:", "Record Id")
objFile.Read
File Object: Example 3-85
/productinfo/alldoc/UNIVERSE10/uv
objs/Ch3
If objFile.Error = UVE_NOERROR Then
' Display the record in a message box and close file
MsgBox objFile.Record
objFile.CloseFile ' Close the file - Good practice
Else
MsgBox "Unable to read (" & objFile.RecordId & ") record
from
å VOC " & objFile.Error
End If
'
' Close the session
'
objSession.Disconnect
Else
'
' Check for Session errors - display message box with error
code
' No error means the user cancelled the connection dialog
box
'
If objSession.Error <> UVE_NOERROR Then
MsgBox "Unable to open connection:- " & objSession.Error
End If
End If
End Sub
(我可以用 C# 很好地编程。我需要一两个关于如何连接到 Universe 9+ 以及如何在 C# 中实例化我需要的“UniObjects”对象的示例。例如,我知道我需要创建一个会话对象,但 VB 6 代码不会告诉我如何在 C# 中做到这一点......)