Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

empty record

Status
Not open for further replies.

sirron

Programmer
Mar 11, 2004
139
US

Im searching a database, and if I can't find any records
return a response. When I run it, its not displaying anything and I'm putting in something thats not in the database.

I put a button on the form but how could I set it up once I click the button it will return the response.write or not.


this is what I set up
If (Recordset1.bof = true and Recordset1.eof = true) then
Response.Write st
 
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/hr_ccn_db.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_hr_ccn_db_STRING
Recordset1.Source = "SELECT user_name FROM user_table"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
If (Recordset1.bof = true and Recordset1.eof = true) then
Response.Write st

%>
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="Adobe PageMill 3.0 Mac">
<TITLE>CSU SITE PREVIEW</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<SCRIPT>
<!--
function new_win()
{
window.open('format/f39.htm','fwind','width=600,height=300,toolbar=no,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
}

function write_date()
{
var thetime=new Date();

var nday=thetime.getDay();
var nmonth=thetime.getMonth();
var ntoday=thetime.getDate();
var nyear=thetime.getYear();
var AorP=" ";

if (nday==0)
nday="Sunday";
if (nday==1)
nday="Monday";
if (nday==2)
nday="Tuesday";
if (nday==3)
nday="Wednesday";
if (nday==4)
nday="Thursday";
if (nday==5)
nday="Friday";
if (nday==6)
nday="Saturday";

nmonth+=1;

if (nyear<=99)
nyear= "19"+nyear;

if ((nyear>99) && (nyear<2000))
nyear+=1900;

document.write( +nmonth+"-"+ntoday+"-"+nyear);
}

//-->
</SCRIPT>
<link href="file:///C|/centralstate.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY BGCOLOR="#666699" LINK="#ffffff" VLINK="#ffffff" ALINK="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<TABLE WIDTH="97%" height="643" BORDER="0" align="center"
CELLPADDING="5" CELLSPACING="0">
<TR>
<TD height="29" BGCOLOR="#404941"></TD>
<TD WIDTH="36%" BGCOLOR="#404941">&nbsp;</TD>
<TD WIDTH="25%" BGCOLOR="#404941"> <P ALIGN=LEFT><font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Welcome.
Today's date is
<script><!--
write_date();
//--></script>
</font></TD>
</TR>
<TR>
<TD width="18%" bgcolor="#90a392"> <div align="center"><img src="images/header1.gif" width="179"
height="72" align="BOTTOM" border="0" naturalsizeflag="3"></div></TD>
<TD width="36%" valign="middle" bgcolor="#90a392"> <div align="right"><font color="#FFFF99" size="7" face="Arial, Helvetica, sans-serif"><strong><u>Human
Resources</u> </strong></font> </div>
<div align="center"></div></TD>
<TD width="25%" bgcolor="#90a392"> <div align="right">&nbsp; <img src="images/header2.jpg" width="215" height="109"
align="BOTTOM" border="0" naturalsizeflag="3"></div></TD>
</TR>
<TR>
<TD HEIGHT="29" BGCOLOR="#5e6b5f" class="text">&nbsp;</TD>
<TD HEIGHT="29" BGCOLOR="#5e6b5f" class="text">&nbsp;</TD>
<TD HEIGHT="29" BGCOLOR="#5e6b5f" class="text">&nbsp;</TD>
</TR>
<TR bgcolor="#5e6b5f">
<TD HEIGHT="438" colspan="3" class="text">
<form name="form1" action="">
<div align="center">
<p align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
<font color="#FFFF00"> <font color="#FFFF99">&nbsp;&nbsp;&nbsp;&nbsp;<font size="3">&nbsp;Please
type in your password to get access to the Employee Action Form</font></font><font size="3">.
&nbsp;&nbsp;</font><font size="4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></font></p>
<p align="center"> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
<font color="#000000"> <strong><font color="#FFFF99">Password:
<input name="txtPass" type="text" id="txtPass">
</font></strong></font></p>
<p align="center">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="Submit" value="Submit">
</p>
</div>
</form></TD>
</TR>
</TABLE>
</BODY>
</HTML>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
 
You haven't specified any criteria in your SQL statement. Your current recordset will contain all the entries in the database.

You might want to change it to something like this...
Code:
"SELECT user_name FROM user_table [COLOR=red]WHERE password='" & Trim(Request.Form("txtPass")) & "'[/color]"

Tony
________________________________________________________________________________
 

If I have this could I run it to see if no records are found?

Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_hr_ccn_db_STRING
Recordset1.Source = "SELECT user_name FROM user_table WHERE user_name = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordsset1_numRows = 0
If (Recordset1.bof = true and Recordset1.eof = true) then
Response.Write st

 
not sure where you are getting Recordset1__MMColParam from. Also you need an End If after your Response.Write st. Either that or put the Response.Write st on the same line as the If...Then

Tony
________________________________________________________________________________
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top