Hi,
I have a text box on a page and a command button. When user enter data into the textbox and then click on the button, a search will be done in the database and data will be returned and displayed on the page. I am able to return the data but how do I set up the click event to tahe the data from the textbox and insert it into my sql string. This is the code I have so far
<%@ LANGUAGE="VBSCRIPT" %>
<%
Option Explicit
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Search_Result</titl
e>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p> </p>
<table width="210" border="0" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<td>Search by Invoice Number </td>
</tr>
<tr>
<td><form action="result" method="get/post" name="invoice" id="invoice">
<input name="invoice" type="text" class="title" id="invoice" value="123456" size="10" maxlength="10">
<input name="Button" type="button" class="button" align="right" onmouseover="this.classNam
e='buttono
n'" onmouseout="this.className
='button'"
value="Search">
</form></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
<%
' -- Declare Variables
Dim objConn ' Our Connection Object
Dim objRS ' Our Recordset Object
Dim strSQL ' Our SQL String to access the database
Dim strConnection ' Our Connection string to access the database
Dim i
' a counter variable
' -- Create objects
Set objConn = Server.CreateObject("ADODB
.Connectio
n")
Set objRS = Server.CreateObject("ADODB
.Recordset
")
objConn.Open "Provider=sqloledb;" & _
"Data Source=localhost;" & _
"Initial Catalog=test;" & _
"Integrated Security=SSPI"
' -- Our SQL Statement
strSQL = "select * from tinvoice where inv_no =12345"
' -- Populate our Recordset with data
set objRS = objConn.Execute (strSQL)
if (objRS.BOF and objRS.EOF) then
response.write "No records found"
response.end
End if
%>
<TABLE BORDER="1" CELLPADDING="2" CELLSPACING="1" WIDTH="100%">
<%
' -- Output the Field Names as the first row in the table
Response.Write "<TR BGCOLOR=""#CCffCC"">"
For i = 0 to objRS.Fields.Count -1
Response.Write "<TH>" & objRS.Fields(i).Name & "</TH>"
Next
Response.write "</TR>"
' -- Now output the contents of the Recordset
objRS.MoveFirst
Do While Not objRS.EOF
' -- output the contents
Response.Write "<TR>"
For i = 0 to objRS.Fields.Count - 1
Response.Write "<TD>" & objRS.Fields(i) & "</TD>"
Next
Response.write "</TR>"
' -- move to the next record
objRS.MoveNext
Loop
objRS.Close
set objRS = Nothing
objConn.Close
set objConn = Nothing
%>