Solved

Multiple inserts from VB6 to Oracle using ADO

Posted on 2003-10-23
4
665 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
  • 2
4 Comments
 
LVL 142

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 50

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 50

Expert Comment

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

822 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