Simple database programming

Soldato
Joined
22 Aug 2005
Posts
8,968
Location
Clydebank
Hi all

I need to develop a simple data base app to search OCR text and return the filename from where the text is found.

I have tried to use SQLite3 and an HTA app (Vbscript) but have only manged to get so far ---

I have all the data in the the DB
I have the app asking for the search term and returning a list of results - however :


When it prints the list of results It uses document.write and clears my page - i.e background graphic.

How do I get a back button, OR configure the search box input again on the results page ?

It's really confusing, as I only have one page, but the search results appear differently ?

This needs to run without a server, i.e. just on a local PC

Code:
<html>
<head>
<title>Database Search</title>
<hta:application id="wycliff"
icon="./graphics/wycliff.ico"
singleinstance="yes"
windowstate="maximize"
>

<script type="text/vbscript">

Sub Window_onLoad
	window.resizeTo 800,500
End Sub
	
	
Function myFunction()
Dim fname
fname=InputBox("Enter Search term, e.g. A person's name","Enter Search Term")
'document.getElementById("mySpan").innerHTML=fname
getResults(fname)
End Function


'This version uses a Database made in sqlite and a DSNless connection
'The ODBC Driver is a special sqlite Driver
 
Const adUseClient = 3
Const adOpenStatic = 3
Const adLockOptimistic = 3
 
Dim objConn, objRS, strQuery
Dim textboxtext
'subroutine for connecting to database and selecting all records in table
sub dbconnect 
Set objConn = CreateObject("ADODB.Connection")
'for a DSN connection follow the example od the code in the next line
objconn.Open "DSN=wycliff"
'for a DSNless connection use code as shown below:
'objConn.Open "DRIVER=SQLite3 ODBC Driver;Database=D:\html progs\clients.db3;"
 
StrQuery = "Select * FROM books ORDER BY book_no"
Set ObjRS = CreateObject("ADODB.Recordset")
ObjRS.CursorType = adOpenStatic
Objrs.LockType = adLockOptimistic
ObjRS.CursorLocation = adUseClient
Set objRS.ActiveConnection = objConn
ObjRS.Open(strQuery)
end sub
 
'routine for closing database
sub closedb
objRS.Close
objConn.close
Set objRS = nothing
Set objConn = nothing
document.clear
window.close
end sub





Function getResults(fname)
    sSQL    = "SELECT page_no, file_path, book_no, book_yr FROM books WHERE page_text LIKE '%" & fname & "%'"
	'document.write sSQL
    Set oRS = objConn.Execute( sSQL )
	document.write "<html><body>"
	
	
	
	document.write "<button onclick='wycliff.hta'>Click me to Search Again</button>"

	document.write "Showing Results: </br>"
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	While not oRs.eof
        document.write "----------</br>", nRec
        For Each oFld In oRS.Fields
            document.write oFld.Name, oFld.Value, "</br>"
        Next
        oRS.MoveNext
Wend


document.write "</body></html>"	

End Function

</script>
</head>
<body>
<body background="bg.gif">
	
	
	
	

<div id = "page"> 
<p class = "heading" >Welcome to Wycliff Database Search Tool</p> 
<br /> 


<script language="VBScript" type="text/vbscript"> 
<!--
'connect to database to get array
call dbconnect
'set up form and fill with first record
'call setupform
' dont need to set up form

objrs.movefirst

//-->
</script>

<button onclick="myFunction()">Click to Enter Search Terms</button>
<span id="mySpan"></span>


</body>
</html>
 
Last edited:
Back
Top Bottom