dbTalk Databases Forums  

Connecting to Unidata using vb.net and uniobjects

comp.databases.pick comp.databases.pick


Discuss Connecting to Unidata using vb.net and uniobjects in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
russell_a_brooke@yahoo.co.uk
 
Posts: n/a

Default Connecting to Unidata using vb.net and uniobjects - 11-10-2005 , 04:47 PM






Hi all,

I'm a veteran unidata/mvbase/universe programmer with lots of
experience. I'm trying to learn vb.net (i have a goodish handle on
normal vb) and would like to write a few applications which access
unidata.

I've tried to look through the unidata 7.1 vb.net developers guide and
i can't make hand nor tail on how to connect to unidata as all the
examples seem to be c# or C and not vb.

If someone could provide a few noddy example on how to connect i would
be very greatful.

I've installed unidata 7.1 pe, so i'm not sure if i will be able to
write applications to connect using this.

I would like to create a form with a connect button, then do some
processing, maybe a few reads, populate a grid with some data, and
maybe write some data away.

Any links would be grand.

Russ


Reply With Quote
  #2  
Old   
bgraetz@bigpond.net.au
 
Posts: n/a

Default Re: Connecting to Unidata using vb.net and uniobjects - 11-14-2005 , 03:39 PM






Hi Russ,

There has been no response, so I will give this a go.

First, if you get hold of the UniData 7.1 or UniVerse 10.1b client
CD-ROM, you will
find sample code in the VB.NET directory tree (see below). If you are
unable to get the client CD, post an e-mail address and I can zip up
the directory tree and e-mail it to you.

I have found the following points helpful when setting up the uo
session for an
application:

1) Create a class to hold the session open and close methods.
2) These methods must be declared as 'Public Shared..'
3) Declared the session handle at the top of Form1 as 'Public Shared
us1...'
4) Because the methods in your class are declared as 'Public Shared..',
you do not
have to initiate the class, you just call the methods (global
functions, I think in
older VB you would use a module rather than a class)

I am not sure if the pe editions allow external connectons, I have
heard a few people
complain that they have been unable to connect through ODBC to the pe
editions,
but I have not tested if this is true. Just be aware there may be a
restriction in the
pe editions.

The following is the sample VB.NET connect code from UniVerse 10.1b
client:

[ start insert ]

Option Explicit On
Option Strict On

' Add the classes in the following namespaces to our namespace
Imports System
Imports System.IO
Imports System.Text
Imports System.Collections
Imports IBMU2.UODOTNET


Class App


Public Shared Function Main(ByVal args() As String) As Integer

Dim us1 As UniSession = Nothing

Try
Console.WriteLine("Program started... ")
us1 = UniObjects.OpenSession("xxxx", "xxxx", "xxxx",
"xxxx", "uvcs")
Catch e As Exception
If Not (us1 Is Nothing) Then
If (us1.IsActive) Then
UniObjects.CloseSession(us1)
us1 = Nothing
End If
End If
Console.WriteLine("")
Dim s As String
s = "Connection Failed : " + e.Message
Console.WriteLine(s)
Finally
If Not (us1 Is Nothing) Then
If (us1.IsActive) Then
Console.WriteLine("")
Dim s As String
s = "Connection Passed"
Console.WriteLine(s)
UniObjects.CloseSession(us1)
Console.WriteLine("Program finished... ")
End If

End If

End Try
Console.Read()
Return 0
End Function 'Main
End Class 'App

[ end insert ]



HTH

Regards Barry


Reply With Quote
  #3  
Old   
russell_a_brooke@yahoo.co.uk
 
Posts: n/a

Default Re: Connecting to Unidata using vb.net and uniobjects - 11-15-2005 , 04:18 PM



Star!

russell_a_brooke (AT) yahoo (DOT) co.uk. If you could send the directory that
would be grand.

Thanks

Russ

bgraetz (AT) bigpond (DOT) net.au wrote:
Quote:
Hi Russ,

There has been no response, so I will give this a go.

First, if you get hold of the UniData 7.1 or UniVerse 10.1b client
CD-ROM, you will
find sample code in the VB.NET directory tree (see below). If you are
unable to get the client CD, post an e-mail address and I can zip up
the directory tree and e-mail it to you.

I have found the following points helpful when setting up the uo
session for an
application:

1) Create a class to hold the session open and close methods.
2) These methods must be declared as 'Public Shared..'
3) Declared the session handle at the top of Form1 as 'Public Shared
us1...'
4) Because the methods in your class are declared as 'Public Shared..',
you do not
have to initiate the class, you just call the methods (global
functions, I think in
older VB you would use a module rather than a class)

I am not sure if the pe editions allow external connectons, I have
heard a few people
complain that they have been unable to connect through ODBC to the pe
editions,
but I have not tested if this is true. Just be aware there may be a
restriction in the
pe editions.

The following is the sample VB.NET connect code from UniVerse 10.1b
client:

[ start insert ]

Option Explicit On
Option Strict On

' Add the classes in the following namespaces to our namespace
Imports System
Imports System.IO
Imports System.Text
Imports System.Collections
Imports IBMU2.UODOTNET


Class App


Public Shared Function Main(ByVal args() As String) As Integer

Dim us1 As UniSession = Nothing

Try
Console.WriteLine("Program started... ")
us1 = UniObjects.OpenSession("xxxx", "xxxx", "xxxx",
"xxxx", "uvcs")
Catch e As Exception
If Not (us1 Is Nothing) Then
If (us1.IsActive) Then
UniObjects.CloseSession(us1)
us1 = Nothing
End If
End If
Console.WriteLine("")
Dim s As String
s = "Connection Failed : " + e.Message
Console.WriteLine(s)
Finally
If Not (us1 Is Nothing) Then
If (us1.IsActive) Then
Console.WriteLine("")
Dim s As String
s = "Connection Passed"
Console.WriteLine(s)
UniObjects.CloseSession(us1)
Console.WriteLine("Program finished... ")
End If

End If

End Try
Console.Read()
Return 0
End Function 'Main
End Class 'App

[ end insert ]



HTH

Regards Barry


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.