Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / March 2008



Tip: Looking for answers? Try searching our database.

VB6 & SQL2000 Stored Proc problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mzv72m - 13 Mar 2008 16:23 GMT
Hopefully someone can help me.  I'm still new to VB development and have been
given a project to support that was developed a few years ago.  We recently
moved the application to a new server and now one the reports that is
produced has more records on it that it should.

The VB code executes a stored procedure to select inventory addition
records.  The problems is that when we run the stored procedure via the VB
code it is returning more records than expected and each time it returns a
different number (290 records, then next 295 recs, etc).  When we run the
stored procedure or just run a similar query through Query Analyzer it always
returns the expected 282 records.

Can someone point me in the right direction on where to look for the problem.

The application is a VB6 app selecting data off a SQL Server 2000 database.  
Below is a snippet of the VB code along with the select statement from the
stored procedure.

Stored Procedure (CreateInvadddelEquipinvRecs):

SELECT *
FROM CURRINV
WHERE VEND_CODE = @vend_code
AND (II_ST IS NULL
    AND IM_ST IS NULL
    AND IA_ST IS NULL
    AND IC_ST IS NULL)
AND VEND_CODE+SERIAL_NO+EQUIP_CODE NOT IN
    (SELECT VEND_CODE+SERIAL_NO+EQUIP_CODE
    FROM PREVINV)
ORDER BY SERIAL_NO,EQUIP_CODE

VB Code:

Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset

cmd.CommandType = adCmdStoredProc
cmd.CommandText = "dbo.CreateInvadddelEquipinvRecs"
cmd.Parameters(1) = VendorCode
Set rs = cmd.Execute()

iRecCount = rs.RecordCount

Thanks,  Dan
MP - 13 Mar 2008 18:43 GMT
> Hopefully someone can help me.  I'm still new to VB development and have
> been
> given a project to support that was developed a few years ago.  We
> recently
> moved the application to a new server and now one the reports that is
> produced has more records on it that it should.

> Set rs = cmd.Execute()
>
> iRecCount = rs.RecordCount
>
> Thanks,  Dan

till someone comes along who actually knows what they're talking about <g>
Are you assuming theres' too many records based on the return from
.RecordCount?
I'm far from an expert but I understand .RecordCount is not reliable
at minimum I think you need to rs.movelast before testing .RecordCount
hth
mark
William Vaughn - 13 Mar 2008 19:07 GMT
Correct. Consider that COM-based ADO returns control to the application
BEFORE rowset population is complete for some cursors. Doing a MoveLast
should complete the population and return a correct rowcount. See "ADO and
ADO.NET Examples and Best Practices (APress)" or "Hitchhiker's Guide to
Visual Basic and SQL Server (6th Edition)" for details--and suggestions
about why it's not a good idea to use SELECT *.

Signature

__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205  (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________

>
>> Hopefully someone can help me.  I'm still new to VB development and have
[quoted text clipped - 17 lines]
> hth
> mark
Dan - 14 Mar 2008 15:03 GMT
Thanks Guys

It looks like this solved my problem.  Something I would have never thought
of.

Dan

> Correct. Consider that COM-based ADO returns control to the application
> BEFORE rowset population is complete for some cursors. Doing a MoveLast
[quoted text clipped - 23 lines]
> > hth
> > mark
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.