Solved

Multiple inserts from VB6 to Oracle using ADO

Posted on 2003-10-23
4
670 Views
Last Modified: 2013-12-25
Hi,

I'm currently developing a DLL in VB 6 which will be contacting an Oracle database over WAN. This file will need to insert between 500 and 1000 rows from a text file to the database as fast as possible. When I've tested the performance of the DLL I've seen the performance is not as good as it should be. So far I've been using a loop like this:
...
    Set Reader = Fso.OpenTextFile(strSQLFileName, ForReading)
    Do Until Reader.AtEndOfStream
      strQuery = Reader.ReadLine
      If Len(strQuery) > 5 Then
          Conn.Execute strQuery
      End If
    Loop
...

Here is an example of the file content:
INSERT INTO c_u_s(c_i, s_g_i, s_f_i, crt_ts, upd_ts, s_v) VALUES('1-07', 'Scope', 'C_OD[2,1]', sysdate, sysdate, '''''');
INSERT INTO c_u_s(c_i, s_g_i, s_f_i, crt_ts, upd_ts, s_v) VALUES('1-07', 'Scope', 'C_ST[2,1]', sysdate, sysdate, '''AAW''');
INSERT INTO c_u_s(c_i, s_g_i, s_f_i, crt_ts, upd_ts, s_v) VALUES('1-07', 'Scope', 'C_SH[2,1]', sysdate, sysdate, '''--H3--''');

Now when I change the above code from
strQuery = Reader.ReadLine
to
strQuery = Reader.ReadAll
I get the error message "[Oracle][ODBC Oracle Driver][Oracle OCI]ORA-00911: invalid character"

I beleive I could improve the performance of the DLL by inserting all rows at once, but my question is, is it possible? And if it is possible how? Do I have to use some other method or object in ADO or?
0
Comment
Question by:GSA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 300 total points
ID: 9605017
you might try this:

strQuery = Reader.ReadAll
strQuery = "BEGIN " & replace(strQuery, vbcrlf, " ") & " END;"

Cheers
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 9605056
Try like:

Private Function ReadFileText(ByVal FileName As String) As String
    On Error GoTo EHandler
    Dim Handle As Integer
    Handle = FreeFile
    Open FileName For Input As #Handle
        ReadFileText = Input$(LOF(Handle), Handle)
        On Error Resume Next
    Close #Handle
    Exit Function
EHandler:
    On Error Resume Next
    Close #Handle
End Function

tmp = ReadFileText("C:\scripts.txt")
tmpArr = Split(tmp, vbcrlf)


for i = 0 to ubound(tmpArr)
       
     Conn.Execute tmpArr(i)

next i
0
 

Author Comment

by:GSA
ID: 9605058
Excellent. How easy life can be some times.

Cheers
Glenn
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 9605064
hmm.. i must be too late to refresh my browser before my post :-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question