Stored Query in Access

Results 1 to 2 of 2

Thread: Stored Query in Access

  1. #1
    Join Date
    Dec 1969

    Default Stored Query in Access

    Im using stored queries in an access database to return counts from my tables. For example here&#039;s a stored query in my test database.<BR><BR>TableCount<BR>"SELECT COUNT(*) AS COUNT FROM Table1 WHERE Table1.ID = [@ID]"<BR><BR>here&#039;s my code:<BR><BR>&#060;!-- #include virtual="/forum/" --&#062;<BR>&#060;%<BR><BR>myDSN = "DSN=myDB"<BR>Set oConn = Server.CreateObject("ADODB.Connection")<BR>oConn.O pen(myDSN)<BR><BR>set cm = Server.CreateObject("ADODB.Command")<BR><BR>cm.Com mandText = "TableCount"<BR>cm.CommandType = adCmdStoredProc<BR><BR>cm.ActiveConnection = oConn<BR><BR>cm.Parameters.Append cm.CreateParameter ("count",adInteger,adParamReturnValue)<BR>cm.Param eters.Append cm.CreateParameter ("@ID",adInteger,adParamInput,4)<BR><BR>cm.Paramet ers("@ID") = 1<BR><BR>cm.Execute<BR>c = cm.Parameters("count")<BR><BR>Response.Write c<BR>%&#062;<BR><BR>I&#039;m trying to just retrieve a return value not a recordset. I&#039;ve searched around to no avail; the only answers seem to suggest I use SQL Server which I dont have. I recieve an error at the Execute method. Any help would be appreciated.<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Stored Query in Access

    &#062;&#062; I recieve an error at the Execute method. &#062;&#062;<BR><BR>Care to share that error with us?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts