|
-
Apr 13th, 2004, 10:39 AM
#1
Thread Starter
New Member
Slow ADO/ODBC to Oracle
Hi, I have VB6 code here to access Oracle 8i with ADO/ODBC. I found the performance is very bad. If I run the same query from SQLPlus, it only takes a few seconds. But with the program it take a few minutes. The bottle neck is the statement of checking rstSource.EOF. I am using Microsoft ODBC for Oracle driver. Any help is appreciated. Thank you in advance.
Private Const CONNECTION_STRING = "DSN=MyDBDev;UID=reader;PWD=readonly"
Private Sub ImportData(strSQL As String)
Dim cnnConn As ADODB.Connection
Dim rstSource As ADODB.Recordset
Dim cmdCommand As ADODB.Command
lblStatus.Caption = "Connecting to DB ..."
' Open the connection.
Set cnnConn = New ADODB.Connection
With cnnConn
.ConnectionString = CONNECTION_STRING
.Open
End With
' Set the command text.
Set cmdCommand = New ADODB.Command
Set cmdCommand.ActiveConnection = cnnConn
With cmdCommand
.CommandText = strSQL
.CommandType = adCmdText
.Execute
End With
lblStatus.Caption = "Retrieving data ..."
Set rstSource = New ADODB.Recordset
rstSource.Open cmdCommand
If Not rstSource.EOF Then '<-- This statement takes very long time to execute!!
ProcessData rstSource
End If
End Sub
-
Apr 13th, 2004, 10:52 AM
#2
Fanatic Member
just for giggles, try the following connection string:
Code:
DBConnection.Open ("Provider=MSDAORA.1;Password=[pwd];User ID=[schema name];Data Source=[db name];Persist Security Info=True")
This way, you bypass ODBC and go direct - and this is know to be significantly quicker
"Knowledge is gained when different people look at the same information in different ways"
- Louis Pasteur
-
Apr 13th, 2004, 11:01 AM
#3
Thread Starter
New Member
Do you mean I can use the similar string you provided and assign it to my CONNECTION_STRING constant? Like this one:
Private Const CONNECTION_STRING = "Provider=MSDAORA.1;Password=readonly;User ID=reader;Data Source=OracleDBName;Persist Security Info=True"
-
Apr 13th, 2004, 11:48 AM
#4
Fanatic Member
yes, and you pass the name of the schema to User ID parameter, db name to the Data Source parameter, and the password to the Password parameter.....you use an ADO connection object:
Code:
dim DBConnection as ADODB.Connection
set DBConnection = New ADODB.Connection
DBConnection.ConnectionString = CONNECTION_STRING
DBConnection.Open
I really am curious how much your query will speed up - according to documentation ODBC can be up to 5 times slower. But if it is still painfully slow, you will have to look at tweaking your query (although if the same query runs fast in SQL*Plus, you should see a difference)....another thing you can try is rather than using the MSDAORA driver (Microsoft), you can try OraOLEDB.Oracle driver (check that website) as this is a native Oracle driver that is reputed to be better than Microsoft's driver. Hope that helps.
"Knowledge is gained when different people look at the same information in different ways"
- Louis Pasteur
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|