vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i
Go Back  Xtreme Visual Basic Talk > > > vb6 connecting to Oracle 9i


Reply
 
Thread Tools Display Modes
  #1  
Old 02-07-2007, 10:09 PM
53050373 53050373 is offline
Newcomer
 
Join Date: Feb 2007
Posts: 1
Default vb6 connecting to Oracle 9i


Dear All,

Good Day. I just completed the 1st testing of using vb6 to connect with the Oracle 9i for my important assignment. So, i do hope anyone who read this and can give me some advices or let me know anyway to improve it or make it better...

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++
Code:
Dim Oracon As ADODB.Connection Dim recset As New ADODB.Recordset Dim objErr As ADODB.Error Dim Message, Title, Default, EmpNoValue Dim EID As Integer, EName As String, EHeight As Integer Dim EEmail As Strin, EWeight As Integer, EBloodType As String i = 0 On Error GoTo err_test Set Oracon = CreateObject("ADODB.Connection") Oracon.ConnectionString = "Provider=OraOLEDB.Oracle;" & "Data Source=sigma;" & _ "User ID=sigma;" & "Password=sigma;" & "PLSQLRSet=1;" Oracon.Open Set recset = New ADODB.Recordset recset.Open "EMPLOYEES", Oracon, adOpenDynamic, adLockOptimistic With recset If Not (.BOF And .EOF) Then While Not .EOF EID = recset.Fields("employeeid").Value EName = recset.Fields("employeename").Value EHeight = recset.Fields("height").Value EEmail = recset.Fields("email").Value EWeight = recset.Fields("weight").Value List1.AddItem EID & " " & EName & " " & EHeight & " " & EEmail & " " & EWeight .MoveNext Wend End If recset.Close End With Exit Sub err_test: MsgBox Error$ For Each objErr In Oracon.Errors MsgBox objErr.Description Next Oracon.Errors.Clear Resume Next End Sub
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++

Also, i am using the ADODB to do the connection, is this suitable to connect with the oracle 9i?

Many Thanks for ur support!

Last edited by Shurik12; 02-08-2007 at 02:04 AM.
Reply With Quote
  #2  
Old 02-08-2007, 02:13 AM
Shurik12vb6 connecting to Oracle 9i Shurik12 is offline
Steppe Walker

Retired Moderator
* Expert *
 
Join Date: Jul 2002
Location: Ukraine/Russia/Belgium
Posts: 7,227
Default

Hi,

1)
Line 2:
Dim recset As New ADODB.Recordset
should become
Dim recset As ADODB.Recordset

2) I'd not use late binding in this context and replace

Set Oracon = CreateObject("ADODB.Connection")

by

Set Oracon = New ADODB.Connection


3) Opening recordset with adOpenDynamic, adLockOptimistic
doesn't seem to be justified here using adOpenForwardOnly,adLockReadOnly
will improve performance

recset.Open "Select * From EMPLOYEES", Oracon, adOpenForwardOnly,adLockReadOnly

And yes ADODB connection is a "suitable" one to use with Oracle
__________________
"A diaper is not like a computer that makes satisfying burbling noises from time to time, hinting at great inner complexity." Malcolm Gladwell

"I'm sitting here completely surrounded by no beer." Onslow, 'Keeping up appearances'
Reply With Quote
  #3  
Old 02-08-2007, 10:39 AM
loquin's Avatar
loquinvb6 connecting to Oracle 9i loquin is offline
Google Hound

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Arizona, USA
Posts: 12,400
Default

You should close and release the ado objects prior to exiting the sub.
Code:
recset.close set recsetnothing oracon.close set oracon=nothing
One other point. The While-Wend loop construct is deprecated in VB5/6, and is only included with backwards compatibility with old pre-VB basic compilers & intrepeters.

The recommended loop construct to use instead of the while/wend is the do...loop

Ref the [snp]***[/sn] looping installment.
__________________
Lou
"I have my standards. They may be low, but I have them!" ~ Bette Middler
"It's a book about a Spanish guy called Manual. You should read it." ~ Dilbert
"To understand recursion, you must first understand recursion." ~ unknown
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i
 
vb6 connecting to Oracle 9i
vb6 connecting to Oracle 9i
 
-->