Click to See Complete Forum and Search --> : Example of how to use RDO to open a connection to a database
LesEvens
Nov 2nd, 1999, 01:23 AM
I'm attempting to use RDO (Remote Data Object) 2.0 with VB6 to open a connection to a database (Informix in this case but it shouldn't matter). I can't seem to get it to work. Does anyone have a code sample that they would be willing to share showing me how to open a connection to a database.
smalig
Nov 2nd, 1999, 01:39 AM
Try it:
Private Sub Sample()
Dim rs As rdoResultset
Dim cn As New rdoConnection
Dim cl As rdoColumn
Dim er As rdoError
On Error GoTo EH
With cn
.Connect = "uid=;pwd=;server=SEQUEL;" _
& "driver={SQL Server};database=pubs;" _
& "DSN='';"
.CursorDriver = rdUseNone
.EstablishConnection rdDriverNoPrompt
Set rs = cn.OpenResultset( _
"select * from titles where Price < 50")
For Each cl In rs.rdoColumns
Debug.Print cl.OrdinalPosition, _
cl.Name, cl.Value
Next
End With
Exit Sub
EH:
For Each er In rdoErrors
Debug.Print er.Description
Next er
Resume Next
End Sub
------------------
smalig
smalig@hotmail.com
smalig.tripod.com (http://smalig.tripod.com)
smalig
Nov 2nd, 1999, 01:41 AM
And I have Oracle connection with RDO:
Sub LoginToDatabase()
Dim Msg$
On Error Resume Next
With rdoCn
.Connect = "DSN=oracle8;UID=guest;PWD=guest;"
.LoginTimeout = 25
.CursorDriver = rdUseOdbc
.EstablishConnection rdDriverNoPrompt, False
End With
Exit Sub
End Sub
------------------
smalig
smalig@hotmail.com
smalig.tripod.com (http://smalig.tripod.com)
LesEvens
Nov 2nd, 1999, 01:55 AM
Thanks smallig. I'm still getting an error (error 429 - Can't Create ActiveX Object). What version of VB are you using? I'm using the Professional Edition. I'm beginning to think that maybe I need the Enterprise edition.
Any thoughts on that.
HeSaidJoe
Nov 2nd, 1999, 02:07 AM
Just a thought...once I was using the dao object but I forgot to reference the object in project references. Same type of error...
'''couldn't create object....
Wayne
LesEvens
Nov 2nd, 1999, 02:09 AM
It's referenced. It points to msrdo20.dll. But thanks for the thoughts.
LG
Nov 2nd, 1999, 02:15 AM
Don't know if it will help you:
check http://support.microsoft.com/support/kb/articles/Q177/3/94.ASP
Good Luck
Larisa
smalig
Nov 2nd, 1999, 02:39 AM
Maybe you need go to 'Project'-'References' and select 'Microsoft Remote Data Object 2.0'?
------------------
smalig
smalig@hotmail.com
smalig.tripod.com (http://smalig.tripod.com)
LesEvens
Nov 2nd, 1999, 02:41 AM
Microsoft data object is selected. Still get the error.
LesEvens
Nov 2nd, 1999, 02:46 AM
Thanks for the input Larisa. I attempted to follow the procedure for the client side of that document and I can't. It says to select an option that I don't have when I execute the dcomcnfg.exe program.
LesEvens
Nov 2nd, 1999, 02:57 AM
What version of Visual Basic are you using Smalig? I'm using the Professional Edition. This code was originally written (and working) with Visual Basic 4.0 Enterprise Edition.
smalig
Nov 2nd, 1999, 03:02 AM
I using VB6 now (3 years ago I started with VB3). Edition doesn't matter for this topic, I think. I have tested both my codes now, but they are working! I don't know your error - ask microsoft :)
------------------
smalig
smalig@hotmail.com
smalig.tripod.com (http://smalig.tripod.com)
LesEvens
Nov 2nd, 1999, 03:08 AM
I first posted a question about this error on 10/29 and got one response back then that said that RDO never worked in VB5 unless you had the Enterprise edition. I understand that you believe that it should work regardless of the edition (I think it should too). However, I have been staring at this problem for so long now that I am going nuts - I have looked all over the internet to see if Microsoft has any solution to the problem. I've tried everything that they suggested - nothing seems to work. I would be happy to ask Microsoft directly if I knew how. How does one ask them a question?
smalig
Nov 2nd, 1999, 03:17 AM
I looked for edition problems but finding only about RDO activex features. I have Enterprise Edition, but it must work in Standard too. You can try EE if it's possible for you.
Best regards.
------------------
smalig
smalig@hotmail.com
smalig.tripod.com (http://smalig.tripod.com)
LesEvens
Nov 4th, 1999, 01:09 AM
Don't know if anybody cares but the problem seems to have been with VB 6 Professional edition. I finally found a Microsoft web site that spoke about my error (search on Q181852). It indicated that there was caused by mismatched .DLLs (between ODBC32.dll and msrdo20.dll). I tried 3 different ODBC32.dll files including one from the VB 6 install CD and they all had the same error. I found a copy of VB 6 on the Visual Studio CD and it worked fine with at least two of the ODBC versions (I never tried the third).
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.