Forums

ASP

This topic is locked

Database connectivity

Posted 13 Sep 2006 08:17:10
1
has voted
13 Sep 2006 08:17:10 maha kalidas posted:
hi all
i have a page that displays records from the database depending on the link clicked, first it doesnot display anything it shows an error but when I navigate between pages and click the bck button it shows the records can u tell me why this error occurs and whats the solution for this. this is my code.


<% option Explicit

Dim objconn, objRS,mySQL
Dim strcount,adOpenForwardOnly,adLockReadOnly,adCmdTable
dim struname
%>

<html>
<head>
</head>
<body>
<%
adOpenForwardOnly = 0
adLockReadOnly = 1
adCmdTable = 2

set objconn = Server.createObject("ADODB.Connection"
objconn.Open "DSN=maha"

mySQL = "SELECT Count(*) AS intTotal FROM users3"
Set objRS = Server.CreateObject("ADODB.Recordset"
objRS.Open mySQL, objConn

objRS.close
Set objRS = Nothing
struname = Request("username"
mySQL = "select * from users3 where user_id ="
mySQL =mySQL & "'"
mySQL =mySQL & struname
mySQL =mySQL & "'"

Set objRS = Server.CreateObject("ADODB.Recordset"
set objRS = objconn.execute(mySQL)
if objRS.EOF then
Response.write "Invalid user id" & "<BR>" & "<a href = '\my web\login.html'><b>go back</b></a>"
else
If objRs("pwd" <> CStr(Request("password") then
response.write "Invalid password" & "<BR>" & "<a href = '\my web\login.html'><b>go back</b></a>"
else
Response.Redirect "validate.html"
end if

end if
objRS.close
objconn.close
set objRS = nothing
Set objconn = nothing

%>

<form width = "100" height = "200" name = "userloginform" method ="post">

</form>

</body>
</html>


and this is the validate.html which contains the hyperlinks..

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css">
<!--
/* General font families for common tags */
font,th,td,p { font-family: Verdana, Arial, Helvetica, sans-serif }
a:link,a:active,a:visited { color : #006699; }
a:hover { text-decoration: underline; color : #DD6900; }
hr { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;}


.cattitle { font-weight: bold; font-size: 15px ; height: 50px; letter-spacing: 1px; color : #006699}
a.cattitle { text-decoration: none; color : #006699; }
a.cattitle:hover{ text-decoration: underline; }
-->
</style>
</head>
<body bgcolor="#E5E5E5" text="#000000" link="#006699" vlink="#5493B4" >
<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
<tr>
<td class="catLeft" colspan="2" height="28"><span class="cattitle"><a href="add.html" target = "view" class="cattitle">Add Issue</a></span></td>
<td class="rowpic" colspan="3" align="right"> </td>
</tr>
<tr>
<td class="catLeft" colspan="2" height="28"><span class="cattitle"><a href="issue.asp" target = "view" class="cattitle">View Issue</a></span></td>
<td class="rowpic" colspan="3" align="right"> </td>
</tr>
</table>

</body>
</html>


and this is my issue.asp

<% option explicit
dim objconn, objRS
dim RecordsPerPage
dim mySQL
dim recordnumber
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css">

th {
color: #FFA34F; font-size: 14px; font-weight : bold;
background-color: #006699; height: 25px;

}
/*background color for the entire page*/
.bodyline { background-color: #FFFFFF; border: 1px #98AAB1 solid; }

/* Main table cell colours and backgrounds */
td.row1 { background-color: #EFEFEF; font-weight: bold; font-size: 16px; color : #006699; }
td.row2 { background-color: #DEE3E7; font-weight: bold; font-size: 16px; color : #006699; }
td.row3 { background-color: #D1D7DC; }


th.thTop,th.thCornerL,th.thCornerR {
font-weight: bold; border: #FFFFFF; border-style: solid; height: 28px;
}

th.thTop { border-width: 1px 0px 0px 0px; }
th.thCornerL { border-width: 1px 0px 0px 1px; }
th.thCornerR { border-width: 1px 1px 0px 0px; }

/* general text */
.gen { font-size : 12px; }
.genmed { font-size : 11px; }
.gensmall { font-size : 10px; }
.gen,.genmed,.gensmall { color : #000000; }
a.gen,a.genmed,a.gensmall { color: #006699; text-decoration: none; }
a.gen:hover,a.genmed:hover,a.gensmall:hover { color: #DD6900; text-decoration: underline; }

/* used for Navigation*/

.nav { font-weight: bold; font-size: 11px; color : #000000;}
a.nav { text-decoration: none; color : #006699; }
a.nav:hover { text-decoration: underline; }



.postdetails { font-size : 10px; color : #000000; }

/* Form elements */
input,textarea, select {
color : #000000;
font: normal 11px Verdana, Arial, Helvetica, sans-serif;
border-color : #000000;
}

/* The text input fields background colour */
input.post, textarea.post, select {
background-color : #FFFFFF;
}

input { text-indent : 2px; }


</style>
</head>


<body bgcolor="#E5E5E5">
<%

RecordsPerPage = 10
set objconn = Server.createObject("ADODB.Connection"
objconn.Open "DSN=maha"
mySQL = "select * from issues"
Set objRS = Server.CreateObject("ADODB.Recordset"
set objRS = objconn.execute(mySQL)
%>

<table width="100%" cellspacing="0" cellpadding="10" border="0" align="center">
<tr>
<td class="bodyline"><table width="100%" cellspacing="0" cellpadding="0" border="0">
</td>
</tr>
</table>
<form>
<table border="1" cellpadding="4" cellspacing="1" width="100%" class="forumline">
<tr>
<th width="50" align="center" height="25" class="thCornerL" nowrap="nowrap"> Issue id </th>
<th colspan = "2" align="center" class="thTop" nowrap="nowrap"> Issue Description </th>
<th width="100" align="center" class="thTop" nowrap="nowrap"> Author </th>
<th width="50" align="center" class="thTop" nowrap="nowrap"> Assigned To </th>
<th align="center" class="thCornerR" nowrap="nowrap"> Raised on </th>
<th align="center" class="thCornerR" nowrap="nowrap"> Closed on </th>
<th align="center" class="thCornerR" nowrap="nowrap"> Issue status </th>
</tr>
<%
if objRS.EOF then
Response.write "<tr><td></td><td></td><td></td><td align = 'center'>"& "No Records found" &"</td>"

Response.write "</tr>"
else
for recordnumber = 1 to RecordsPerPage
%>
<tr>
<td class="row2" align="center" valign="middle" height="50"><span class="thTop"><%= objRS("issue_id"%></span></td>
<td colspan = "2" class="row2" width="100%" height="50"><span class="thTop"><%= objRS("issue_desc"%></span></td>
<td class="row2" width="100%" height="50"><span class="thTop"><%= objRS("user_name"%></span></td>
<td class="row2" width="100%" height="50"><span class="thTop"><%= objRS("assigned_user"%></span></td>
<td class="row2" width="100%" height="50"><span class="thTop"><%= objRS("issue_date"%></span></td>
<td class="row2" width="100%" height="50"><span class="thTop"><%= objRS("closed_date"%></span></td>
<td class="row2" width="100%" height="50"><span class="thTop"><%= objRS("issue_status"%></span></td>
</tr>
<% objRS.moveNext
if objRS.EOF then
exit for
end if
Next

end if
%>

</table>
<br><br>
<%
objRS.close
objconn.close
set objRS = nothing
set objconn = nothing
%>
<table border = "0" width = "100%" align = "center">
<tr>
<td align = "center">
<input type="submit" align = "center" name = "button1" value = "back">
</td>
</tr>
</table>
</form>
</html>

can anyone help me out please.. am very near to my deadline but not able to figure out whats wrong...


Reply to this topic