PC Review
Forums
Newsgroups
Microsoft Word
Microsoft Frontpage
Please help me with this function!
Forums
Newsgroups
Microsoft Word
Microsoft Frontpage
Please help me with this function!
![]() |
Please help me with this function! |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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" <laverf@hotmail.com> wrote in message news:b2c1fef.0401231112.5b3dec13@posting.google.com... > 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 |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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" <laverf@hotmail.com> wrote in message news:b2c1fef.0401231112.5b3dec13@posting.google.com... > 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 |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

