[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 529
  • Last Modified:

Running a count query for SQL in VB6

Im am trying to get a record count for a SQL table from VB6
i have tried the following but i dont know where the ouput(if there is going to be any) will be.
   
    Dim intCount As String
    Dim adoBEN As New ADODB.Command
    Dim rsBEN As New ADODB.Recordset
    adoBEN.ActiveConnection = "dsn=depfund"
    adoBEN.CommandText = "select count (*) from Beneficiary where service_number = '" & intsnum & " '"
    adoBEN.CommandType = adCmdText
    Set rsBEN = adoBEN.Execute()
    intCount = rsBEN
   
I also created a ado control and tried the following to no avail. It seems to work for a access db.
   
    adoCount.RecordSource = "select count (*) from Beneficiary where service_number = '" & intsnum & "'"
    adoCount.Refresh
    txtCount = adoCount

i have run the query in analyzer and it works fine....i have also made sure the intsnum variable contains a value when run.
Please let me know what im doing wrong.
thanks
0
dolfie99
Asked:
dolfie99
1 Solution
 
lakshman_ceCommented:
Get the RecordCount property on the ADODB.Recordset object

intCount = resBEN.RecordCount

txtCount = adoCount.RecordSet.RecordCount

Also look at these links
http://www.vbtutor.net/lesson21.html
http://www.devarticles.com/c/a/Visual-Basic/Implementing-An-ADO-Data-Control-With-VB6/
0
 
dolfie99Author Commented:
Thanks for that

the inCount did not work, but the second one did. Dont know why and dont really care now.

Cheers
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now