PC Review


Reply
Thread Tools Rate Thread

Please help me with this function!

 
 
Jiador
Guest
Posts: n/a
 
      23rd Jan 2004
Hi,

This is a VBscript function that I have in my asp page and when I call
it, I get this error:
Type mismatch: ‘RecCount'

Function RecCount (tablename)
dim oConn
dim rs
dim strSQLQuery

set oConn = Server.CreateObject("ADODB.Connection")
oConn.Provider="Microsoft.Jet.OLEDB.4.0"
oConn.Open "C:\Inetpub\wwwroot\GCIP_WEB\fpdb\GCIP_DB.mdb"

set rs = Server.CreateObject("ADODB.recordset")
strSQLQuery = "SELECT * FROM " & tablename
rs.Open strSQLQuery, oConn

set RecCount = rs.RecordCount
rs.close
set rs = nothing
oConn.close
set oConn = nothing

end Function

And here is the call:

<input type="button" value="Record" name="Record" onclick=
"Document.write '<p>'& RecCount('GCIP_CASES') & '</p>' " Language =
"VBscript" > </p>

Can anybody tell me what I'm doing wrong ?
Thank you
Jiador
 
Reply With Quote
 
 
 
 
Jon Spivey
Guest
Posts: n/a
 
      23rd Jan 2004
Hi,
you'd need to hit the server (ie submit a form) to run this function. You
can't run asp from the client -
<%
Function RecCount(tablename)
' code
end function
if request.form <> "" then
response.write RecCount("GCIP_CASES")
else
%>
<form method="post" action="this page.asp">
<input type="submit">
<%end if%>

--
Cheers,
Jon
Microsoft MVP - FP

"Jiador" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> This is a VBscript function that I have in my asp page and when I call
> it, I get this error:
> Type mismatch: 'RecCount'
>
> Function RecCount (tablename)
> dim oConn
> dim rs
> dim strSQLQuery
>
> set oConn = Server.CreateObject("ADODB.Connection")
> oConn.Provider="Microsoft.Jet.OLEDB.4.0"
> oConn.Open "C:\Inetpub\wwwroot\GCIP_WEB\fpdb\GCIP_DB.mdb"
>
> set rs = Server.CreateObject("ADODB.recordset")
> strSQLQuery = "SELECT * FROM " & tablename
> rs.Open strSQLQuery, oConn
>
> set RecCount = rs.RecordCount
> rs.close
> set rs = nothing
> oConn.close
> set oConn = nothing
>
> end Function
>
> And here is the call:
>
> <input type="button" value="Record" name="Record" onclick=
> "Document.write '<p>'& RecCount('GCIP_CASES') & '</p>' " Language =
> "VBscript" > </p>
>
> Can anybody tell me what I'm doing wrong ?
> Thank you
> Jiador



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      23rd Jan 2004
You're mixing up client- and server-side code. Assuming that your "RecCount"
function is a server-side function, you're attempting to call it in a
client-side VBScript. Once the page reaches the client browser, the server
is all but forgotten, and most certainly out of reach.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Jiador" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> This is a VBscript function that I have in my asp page and when I call
> it, I get this error:
> Type mismatch: 'RecCount'
>
> Function RecCount (tablename)
> dim oConn
> dim rs
> dim strSQLQuery
>
> set oConn = Server.CreateObject("ADODB.Connection")
> oConn.Provider="Microsoft.Jet.OLEDB.4.0"
> oConn.Open "C:\Inetpub\wwwroot\GCIP_WEB\fpdb\GCIP_DB.mdb"
>
> set rs = Server.CreateObject("ADODB.recordset")
> strSQLQuery = "SELECT * FROM " & tablename
> rs.Open strSQLQuery, oConn
>
> set RecCount = rs.RecordCount
> rs.close
> set rs = nothing
> oConn.close
> set oConn = nothing
>
> end Function
>
> And here is the call:
>
> <input type="button" value="Record" name="Record" onclick=
> "Document.write '<p>'& RecCount('GCIP_CASES') & '</p>' " Language =
> "VBscript" > </p>
>
> Can anybody tell me what I'm doing wrong ?
> Thank you
> Jiador



 
Reply With Quote
 
 
 
Reply

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Function Question: Collect Condition in Dialog Box - But How toInsert into Function Equation? SteveM Microsoft Excel Programming 1 3rd Jan 2008 04:45 PM
I have a CLR function thet returns IEnumberable (a table) and it has a FillRow function. I am returning 10,000 integers from this function. Is there any way that I can preallocate the resulting table or give SQL server hint as to how many rows my fun DR Microsoft Dot NET Framework 1 22nd Nov 2007 12:36 PM
I have a CLR function thet returns IEnumberable (a table) and it has a FillRow function. I am returning 10,000 integers from this function. Is there any way that I can preallocate the resulting table or give SQL server hint as to how many rows my fun DR Microsoft ADO .NET 3 22nd Nov 2007 10:17 AM
I have a CLR function thet returns IEnumberable (a table) and it has a FillRow function. I am returning 10,000 integers from this function. Is there any way that I can preallocate the resulting table or give SQL server hint as to how many rows my fun DR Microsoft VB .NET 0 20th Nov 2007 05:24 AM
I have a CLR function thet returns IEnumberable (a table) and it has a FillRow function. I am returning 10,000 integers from this function. Is there any way that I can preallocate the resulting table or give SQL server hint as to how many rows my fun DR Microsoft Dot NET 0 20th Nov 2007 05:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:39 PM.