---------------
Hi Please go through follwong code. If u dont understand mail be back.
Here first i am checking value in the text box. If there is any value then I am searching with that string.
Thanks
Suresh(
[email protected])
---------------
<%@ Language=VBScript %>
<%
If Request.Form("tEmpId") <> "" Then
Dim objRs,objConn,cstrSql
set objRs = server.CreateObject("ADODB.RECORDSET")
set objConn = server.CreateObject("ADODB.CONNECTION")
cstrSql = "select empno,ename from employee where empno=" & cint(Request.Form("tEmpId"))
objConn.ConnectionString = "Provider=sqloledb.1;UID=sa;pwd=007;database=sampl e;DSN=user-37"
objRs.CursorLocation = 3
objConn.Open
objRs.Open cstrSql,objConn,3,2
End If
%>
<HTML>
<HEAD>
<script>
function checkId(e)
{
if(e.keyCode >= 48 && e.keyCode <=57)
{
return true;
}
else
{
return false;
}
}
</script>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<form name=fEmp action="EmployeeSearch.asp" method=post>
<input type=text name="tEmpId" onkeyPress="return checkId(event)"> &nbs p;
<input type=submit>
<%If Request.Form("tEmpId") <> "" Then%>
<%If objRs.RecordCount > 0 Then%>
<Table border=1>
<TR align=center>
<TD><b>Employee ID</b></TD><TD><b>Employee Name</b></TD>
</TR>
<TR align=center>
<TD><%=objRs("empno")%></TD><TD><%=objRs("ename")%></TD>
</TR>
</Table>
<%End If
set objRs= nothing
set objConn = nothing
%>
<%End If%>
</form>
<P> </P>
</BODY>
</HTML>