[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Multiple inserts from VB6 to Oracle using ADO

Posted on 2003-10-23
4
Medium Priority
?
690 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 143

Accepted Solution

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

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

Cheers
0
 
LVL 54

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 54

Expert Comment

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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

830 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