Link to home
Start Free TrialLog in
Avatar of Mike McCracken
Mike McCracken

asked on

MDAC - VB6 - MS SQL Server

We are about to field an databse application.  The front end is written in VB 6 using ADO with MDAC 2.5.  The back end is MS SQL Server 7.0.

Until the last week everything worked well in both the development and production environments.  When we tested some changes on the Production LAN we started getting some strange results.

Forms with date fields display properly so long as a record exists (even with NULL for the date field).  If no record exists then we get 30 Dec 1899 displayed as the date.  On several of the forms if a date is in certain fields, the form is locked from changes even though no record exists.

There have been no changes on the development LAN (we control it) and everything is working fine.  On the production LAN they recently upgraded to MDAC 2.7.  

As a test we rebuilt one our production side machines with an old load (MDAC 2.5) and everything is working fine.  The code run was the same as on machines with MDAC 2.7.

Does anybody have any ideas on what we can do?  

mlmcc
Avatar of Cimperiali
Cimperiali
Flag of Italy image

>As a test we rebuilt one our production side machines with an old load (MDAC 2.5)
You should do the contrary: install mdac2.7, open your projects, change reference to the proper "micorsoft ActiveX Data Object (2.7) library" and then try your software...
Avatar of Mike McCracken
Mike McCracken

ASKER

We tried that.  Still have the same problem.

mlmcc
you need to register on client machine msvbvm60.dll
just as a note:

30 Dec 1899

is the Date when the value returned is treated as 0.  In VB 6, Date variables are handled internally as NUMBERS or type Single (a number WITH as Decimal point), such that the Integer part of the value (to the LEFT if the decimnal point) is the Number of Days since 12/31/1899  and the Fractional part is the Fraction of 1 day, as measured in Seconds from MIDNIGHT.

sounds like you are not handling NULL dates properly.  

AW
>>30 Dec 1899 is the Date when the value returned is treated as 0.  

We realized what the date meant.  What we don't understand is how come it is suddenly causing a probelm.



>> sounds like you are not handling NULL dates properly

This only occurs when the record doesn't exist.  If the record is built with only the PK fields we don't have a problem.  


>>you need to register on client machine msvbvm60.dll

Happens even on a machine with Visual Studio installed. Also, the application was fine last week.  We made no changes to the application or the machine other than MDAC 2.7 was pushed.  Could the push have unregister msvbvm60?

mlmcc
As Arthur has pointed out, the problem has to do with not handling dates correctly.

>>We made no changes to the application or the machine other than MDAC 2.7 was pushed. <<
This is not the full picture, is it?  The Production data is different to the Development data.  To prove this: Move the Production data to the Development environment and you will probably see the same there.

Anthony
Actually that is the full picture.

Installed MDAC 2.7 on a development workstation.  Ran the applicatioin.  As expected we have the same problem.  

Changed the reference from MDAC 2.5 to MDAC 2.7.  Recompiled the application.  Still have the same problem.

Selected a simple form.  Added a new ADO control.  Pointed some of the date fields to it.  These fields showed as blank when the application was recompiled.

Solution
Delete and rebuild all ADO controls in the application.

mlmcc
Actually the problem was when you said you were using the ADO control <smile> Since I have never used the ADO Data Control (and don't intend to) I have never come across this problem and trust me if this is the only problem you have encountered using them, then you must walk on water <g>

Anthony
acperkins :
What do you use for dat access?

mlmcc
>>What do you use for dat access?<< I do not use the ADO Data control, instead I write code (using ADO).  I also, very rarely use bound controls, except perhaps for a grid control. The prime advantage is that you as a programmer have far better control of what is happening.

The last time I used a Data Control was over 6 years ago using DAO, I learned my lesson and never repeated the same mistake twice.

Anthony
We may decide to take that approach since we have to change all the controls anyways.  May decide to convert to VB recordsets or VB recordsets using database views and stored procedures.

mlmcc
I have solved the problem.  The problem ado controls were set to adAddNew on the EOFAction.  This creates a new record and apparently ADO 2.7 puts 0 in for the date rather than null.

We changed the property of all the ado controls and the application now runs as expected.  

mlmcc
I have no problem that they PAQ this question.

Anthony
ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial