Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old August 9th, 2004, 02:40 AM
procrastinatorX procrastinatorX is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 13 procrastinatorX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 21 sec
Reputation Power: 0
Red face Odd Problem with the ADO DataControl

Hi Guys/Gals hope you can help me on this one. I'm maintaining a POS System which my former collegues of mine developed, where in some forms they use a ADO Data Control to connect to the database with no problems. The issue is that when I run the program, the Data Control is disabled, and querying the recordcount property reveals that it has no records in it. This problem (i think) occured when i installed the visual studio service pack 6. I tried uninstalling and reinstalling VB 6 but with no positive results, i tried to downgrade the MDAC to a lower version but it still does not work .
Any help on this one would be greatly appreciated, thnx.

Reply With Quote
  #2  
Old August 10th, 2004, 06:06 AM
Mythomep Mythomep is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Zaandam, The Netherlands
Posts: 70 Mythomep User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 37 sec
Reputation Power: 4
Send a message via MSN to Mythomep
Hi,

The recordcount property is a very weird property. It is not always initialized, and will sometimes display an incorrect number of records. It all depends on several factors (Provider, Cursortype and Cursorlocation). If you say that the recordcount is 0, does the recordset indeed contain no records?

To make sure that a recordset is properly populated, use two move commands. First one to move to the last record of the set, and the other to move to the first record in the set. That should update the recordcount with correct value.

The following code excerpt will tell you if the recordcount property is supported:

Code:

  If (rsObject.Supports(adApproxPosition)) OR (rsObject.Supports(adBookmark)) then
	msgbox "Recordset supports the use of .RecordCount", vbOkOnly + vbInformation, "Sample - Message"
  Else
	msgbox "Recordset does not support the use of .Recordcount." & vbCrLf & _
		   "Using .RecordCount drains resources, because the provider" & vbCrLf & _
		   "has to retrieve and count all the records (not very accurate).", _
		   vbOkOnly + vbInformation, _
		   "Sample - Message"
  End If


Downgrading your version of the MDAC has no effect. ADO downgrades or upgrades on its own (taken you did not take steps to prevent that from happening). When I have a problem like this, especially with inherited code, I always look for the SQL statement and execute that on the database itself. Most likely you got a case of code-rot, and some field has a value that isn't right or some constructs used in the code are no longer valid.

Hope this is of some help, if not please forgive me. If you got more questions, feel free to ask them.

Grtz.©

M.

Reply With Quote
  #3  
Old August 11th, 2004, 12:34 AM
procrastinatorX procrastinatorX is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 13 procrastinatorX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 21 sec
Reputation Power: 0
Quote:
Originally Posted by Mythomep
Hi,

The recordcount property is a very weird property. It is not always initialized, and will sometimes display an incorrect number of records. It all depends on several factors (Provider, Cursortype and Cursorlocation). If you say that the recordcount is 0, does the recordset indeed contain no records?

To make sure that a recordset is properly populated, use two move commands. First one to move to the last record of the set, and the other to move to the first record in the set. That should update the recordcount with correct value.

The following code excerpt will tell you if the recordcount property is supported:

Code:

If (rsObject.Supports(adApproxPosition)) OR (rsObject.Supports(adBookmark)) then
	msgbox "Recordset supports the use of .RecordCount", vbOkOnly + vbInformation, "Sample - Message"
Else
	msgbox "Recordset does not support the use of .Recordcount." & vbCrLf & _
		 "Using .RecordCount drains resources, because the provider" & vbCrLf & _
		 "has to retrieve and count all the records (not very accurate).", _
		 vbOkOnly + vbInformation, _
		 "Sample - Message"
End If


Downgrading your version of the MDAC has no effect. ADO downgrades or upgrades on its own (taken you did not take steps to prevent that from happening). When I have a problem like this, especially with inherited code, I always look for the SQL statement and execute that on the database itself. Most likely you got a case of code-rot, and some field has a value that isn't right or some constructs used in the code are no longer valid.

Hope this is of some help, if not please forgive me. If you got more questions, feel free to ask them.

Grtz.©

M.

Thnx very much for the reply, tested the recordset with the code you gave, and it indeed

supports the recordcount property, and further testing i did was to put simple datacontrol side-

by-side with the existing ADODC, and guess what, the normal datacontol gets populated while

the ADODC does not. well, thanks for the effort, anyways, still searching for an answer, thnx

again.

Reply With Quote
  #4  
Old August 11th, 2004, 03:27 AM
Mythomep Mythomep is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Zaandam, The Netherlands
Posts: 70 Mythomep User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 37 sec
Reputation Power: 4
Send a message via MSN to Mythomep
Hi,

If you made a new ADODC connection and that one works, we might be able to see where the error is by comparing settings on both datacontrols. Things you might want to compare on the recordset are cursorlocation and cursortype. On the dataconnection you might want to check database connection settings like usernames and passwords, database locations and (in the case of SQL Server) client protocol settings. These settings can interrupt the retrieval of data.

If all else fails, you might want to swap the old defunct datacontrol for the new functional datacontrol. Sometimes MS works in mysterious ways, and you might have a case of "Uncle Billy's joke".

Grtz.©

M.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Odd Problem with the ADO DataControl


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway