Solved

Multiple inserts from VB6 to Oracle using ADO

Posted on 2003-10-23
4
658 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
Comment Utility
you might try this:

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

Cheers
0
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
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
Comment Utility
Excellent. How easy life can be some times.

Cheers
Glenn
0
 
LVL 49

Expert Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now