VB Code run differently based on Compilation

VB Code run differently based on Compilation

Post by Cynthia Merrit » Fri, 16 Jan 1998 04:00:00



I have written a huge program that updates tables on MS-SQL Server 6.5. It
is basically a whole bunch of SQL statements which read a flat file of data
and parse it  into the various SQL Server tables.  It is written in VB 5.0,
the Professional Edition.  The program will compile, either to p-code,
n-code, or optimized n-code (which takes forever).  The program executes
without error messages, whatever method of compilation is chosen.

However (you knew this was coming!)... the program seems to randomly ignore
lines from the flat file being processed.  It also seems to have varying
results based on how it was compiled.  When optimized to native code, more
lines of the flat file seem to be ignored.  As I tried the more basic
compiles, more lines of the flat file seemed to be processed, but I still
seem to be missing some lines.

How can this be?  Is it possible that it is running too fast on the SQL
Server?  The executable is launched on the SQL Server box, using named pipes
to communicate with the SQL Server tables.  It really screams this way, but
why are lines being dropped/ignored?  Have any of you ever encountered this?

All help, information, prayers gratefully accepted. Please email me if
possible, as it's difficult to get to these newsgroups too often.

Thanks!

--
Cynthia A. Merritt
Compressor Controls Corporation

 
 
 

VB Code run differently based on Compilation

Post by Joel Shepher » Sat, 17 Jan 1998 04:00:00


I doubt if the problem is in the way the program is compiled. It's
_possible_, but compilers are a pretty highly evolved breed of software, and
it's unlikely that an error causing a change in program semantics would make
it through.

It might be more fruitful to try to get a better idea of what the code is
doing, and why. The first thing that popped in my head when I read this is
that somewhere in the code there's an "On Error Resume Next" statement, that
is swallowing some critical error that's causing the incorrect behaviour.
The error shouldn't occur if the code is working correctly, but it does
occur and unfortunately never catches your attention because of the "Resume
Next".

What if that's not it? The next thing -- it seems to me -- is to have the
program log everything it's doing, so you can determine exactly what kind of
data it's blowing up on. Have it log each line it reads, and each record it
inserts/updates in the database. It'll slow things down, but it'll give you
a lot of information to work with.

Finally (or maybe first) take a limited bit of data the program is known to
blow up on -- maybe ten records or so -- and walk through the code in the
IDE (the F8 key is your friend), so you can see exactly what the code is
doing. You may be surprised and find it isn't quite doing what you thought.


>I have written a huge program that updates tables on MS-SQL Server 6.5. It
>is basically a whole bunch of SQL statements which read a flat file of data
>and parse it  into the various SQL Server tables.  It is written in VB 5.0,
>the Professional Edition.  The program will compile, either to p-code,
>n-code, or optimized n-code (which takes forever).  The program executes
>without error messages, whatever method of compilation is chosen.

>However (you knew this was coming!)... the program seems to randomly ignore
>lines from the flat file being processed.  It also seems to have varying
>results based on how it was compiled.  When optimized to native code, more
>lines of the flat file seem to be ignored.  As I tried the more basic
>compiles, more lines of the flat file seemed to be processed, but I still
>seem to be missing some lines.

>How can this be?  Is it possible that it is running too fast on the SQL
>Server?  The executable is launched on the SQL Server box, using named
pipes
>to communicate with the SQL Server tables.  It really screams this way, but
>why are lines being dropped/ignored?  Have any of you ever encountered
this?

>All help, information, prayers gratefully accepted. Please email me if
>possible, as it's difficult to get to these newsgroups too often.

>Thanks!

>--
>Cynthia A. Merritt
>Compressor Controls Corporation



 
 
 

1. Create aview to behave differently based on columns requested

I have a dynamic query system that depends on a single view for it to retrieve
rows for reports.

The tables I have to work with require that the view contains an outer join to
permit some columns to appear.

However, if the users don't ask for any of the columns from the outer joined
table, I would like to avoid performing the outer join.

Tables:
A:  Basic order data
B:  Details of the orders
  - Spoons
  - Forks
  - Toasters (with a serial number)

S: The serial number table, only has rows with serial numbers

If a person is asking for just the details of the order, like how many spoons
forks and toasters are in the order, I can do an inner join of tables A and B.

If they want just the parts of the order with serial numbers, I can do an inner
join of all 3 tables.

However, if they want an order with all the forks and spoons, plus all serial
numbers of the toasters, I gotta do an outer join, or the forks and spoons won't show up.

What I would like to be able to do is have a conditional view that did:

If they aren't asking for serial number, just inner join A and B

Else, if they ONLY want records WITH serial numbers, inner Join A, B and S

Otherwise, if they want serial numbers , plus the items without serial numbers,
inner join A and B and outer Join S

To do this, I need to test the columns they are requesting, and then use the
appropriate join.

I cannot change the code to ask for more than one view (probably a good idea,
but impossible right now

I'd like the view to be 'smart'

Is this possible?

From: John B. Rees

2. Passing parameter to Stored Procedures from VB

3. vb code need for my first data base in vb5 from carl

4. Changing OnLine mode during restore...

5. UPDATE behaves differently in compliled code

6. Sybase NetGateway

7. What is better, Load VB Code vs Executing Package with VB Code

8. backend

9. Identical query runs differently on two servers

10. Stored Procedure behaving differently when run in Query Analyzer vs Job

11. run vb code whenever writing/reading to a table

12. Running Access97 VBA code from a VB App

13. Problem running VB code on SQL Server from Access Project