Count of records

D

David Kennedy

Hi,
I have an Access table with 2 fields (TName,Checked).
Field TName contains a list of 300 table names in a database in SQL Server
2000.
Field Checked (Data type Text),has a value inserted, if the count of records
in a table needs to be calculated.
I have added a new field to this table called NumOfRecords, which I want to
hold the count of records of a table where field Checked has a value.

Here is a section of code I have written,but I need help in filling in the
blanks.


With objRs
.MoveFirst
Do While Not .EOF
If .Fields(1).Value <> "" Then
SQLtblName = .Fields(0).Value
SQLtblName = "[" & SQLtblName & "]"
intStrLen = Len(SQLtblName)
objConn.ActiveConnection = CurrentProject.Connection
objConn.CommandType = adCmdStoredProc
objConn.CommandText = "sp_CountSQLRecs"

Set objParam = objConn.CreateParameter("@tblName", adVarChar,
adParamInput, intStrLen, SQLtblName)

****How do I capture the count of records returned
from the stored procedure?******

objConn.Parameters.Append objParam
objConn.CommandTimeout = 0
objConn.Execute


.Edit
.Fields(2).Value = SQLrecCount
.Update

Else
'.MoveNext
End If
.MoveNext
Loop
End With


here is the stored procedure I have created,I dont know if its correct.

CREATE PROCEDURE sp_CountSQLRecs
@tblName varchar,
@recCount varchar OUTPUT

AS
SELECT COUNT(*) AS @recCount
FROM @tblName

RETURN @recCount
GO
END


Any help would be appreciated
Thanks
David Kennedy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top