Skip to content

Instantly share code, notes, and snippets.

@evagoras
Created September 28, 2023 14:06
Show Gist options
  • Save evagoras/91e8d85256bd36ac6a881c2fcf86e5f8 to your computer and use it in GitHub Desktop.
Save evagoras/91e8d85256bd36ac6a881c2fcf86e5f8 to your computer and use it in GitHub Desktop.
Calling MS Access Parameterized Queries from ASP
...
strQuery = "faq_qry_sub_categories '" & numCategoryID & "', '" & secondparam & "'"
...
...
Dim numCategoryID
numCategoryID = Request.Form("CategoryID")
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/faqs.mdb")
Set objRS = Server.CreateObject("ADODB.Recordset")
strQuery = "faq_qry_sub_categories '" & numCategoryID & "'"
objRS.Open strQuery, objConn, 0, 4
...
<%
Dim objConn
Dim objRS
Dim strSQL
Dim numCategoryID
numCategoryID = Request.Form("CategoryID")
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/faqs.mdb")
Set objRS = Server.CreateObject("ADODB.Recordset")
strQuery = "SELECT faq_category.ID, " _
& "Count(faq_category.name) AS count, " _
& "faq_category.name, faq_category.description "_
& "FROM faq_category " _
& "INNER JOIN faq_faq ON faq_category.ID = faq_faq.category_ID " _
& "GROUP BY faq_category.ID, faq_category.name, " _
& "faq_category.description, faq_category.parentID " _
& "HAVING faq_category.parentID=" & numCategoryID _
& " ORDER BY faq_category.name;"
objRS.Open strQuery, objConn, 0, 1
'-- continue with writing your recordset out
...
%>
...
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/faqs.mdb")
Set objRS = Server.CreateObject("ADODB.Recordset")
strQuery = "faq_qry_sub_categories"
objRS.Open strQuery, objConn, 0, 4
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment