473,326 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Can any one help me to correct my syntax?

----------------------Below are all the codes don't have errors----
The only problem I have is when I Delete, I'ts not deleting the subject that I click.
I want to use the above codes to modify the code in "line 168"and in line"393"

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%Option Explicit%>
<%
Dim strCourseCode
Dim strSubjectCode
Dim strSubjectName
Dim objConn
Dim rsCheck
Dim sConnString
Dim strSQL
Dim Conn
Dim sConnection
Dim mysql
Dim strSQL2
Dim strDeleteRecord
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<H3 align="center">Subject Specification per Course</H3>
<%strCourseCode = request.form("txtCourseCode")%>
<%
Session("CourseCode") = strCourseCode
'Response.Write(Session("CourseCode"))
'Session.Contents.Remove("CourseCode")
%>


<form name="form1" method="post" action="Management_SubjectCourse.asp?action=View">
</p>

<table width="137" border="0" align="center">
<tr>
<td width="62"> <span style="font-weight: bold">Course Code:</span></td>
<td width="65"><%
Set objConn = Server.CreateObject("ADODB.Connection")
Set rsCheck = Server.CreateObject("ADODB.Recordset")
sConnString = "Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("student.mdb") & ";" & _
"Persist Security Info = False"
objConn.Open(sConnString)

strSQL = "SELECT CourseCode FROM Course"
rsCheck.Open strSQL, objConn
%>
<select name="selectCourseCode">

<%If strCourseCode = "" then%>


<option value=""> </option>
<%else%>




<option value ="<%=request.form("txtCourseCode")%>" selected="selected"> <%response.write(request.form("txtCourseCode"))% ></option>
<!--
<option value ="" selected="selected"></option>
-->
<%Session.Contents.Remove("CourseCode")%>
<%end if%>
<%
do while not rscheck.EOF
%>

<option value="<%=rscheck("CourseCode")%>"><%=rscheck("Cou rseCode")%></option>
<%
rscheck.movenext
loop
%>
</select>
</td>
</tr>

<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="View" /></td>
</tr>
</table>
</form>
<%'Response.Write Request.Cookies("Cookies")%>
<%'Response.Cookies("Cookies").expires = now%>
<!--<!--<!-- -->
<%IF Request.QueryString("action") = "View" then%>
<br />
<%
if strCourseCode = "" then
strCourseCode=Request.form("selectCourseCode")
else
strCourseCode = request.form("txtCourseCode")
end if
Response.Cookies("Cookies") = strCourseCode
Response.Cookies("CourseCode") = strCourseCode
%>


<table align="center">


<table border="0">
<tr>
<td><div align="center"><strong>Course Code:</strong></div></td>

<td><%Response.Write Request.Cookies("CourseCode")%></td>
</tr>
</table>

<%






Set Conn = Server.CreateObject("ADODB.Connection")
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("student.mdb") & ";" & _
"Persist Security Info=True"
Conn.Open(sConnection)


mysql="SELECT * FROM SubjectCourse where CourseCode='" & strCourseCode & "'"
set rsCheck = Conn.Execute(mysql)

if strCourseCode = "" then
%>
<p>
<center>
<table width="200" border="0">
<tr>
<td> <span style="font-weight: bold">

</span></td>
</tr>
</table>
</p>
</center>


<%
Else
Response.write "<center> <table width=100% border=1><tr>"
%>

<% Response.write "<th width=15% align=center> " & "" & "</th>" %>

<% Response.write "<th width=15% align=center> " & "Subject Code:" & "</th>" %>
<%
Response.write "<th width=15% align=center>" & "Subject Name:" & "</th>"




While not rsCheck.EOF
Response.write "<tr>"



'

Response.write "<td>" & "<center> <a href = Management_SubjectCourse.asp?action=Delete> DELETE</a> </center>" & "</td>"
Response.cookies("DeleteCookies") = rsCheck(2).Value
%>
<!--<input name="txtDelete" type="hidden" value='<%'=rsCheck(0)%>'/> -->
<%

'

Response.write "<td>" & "<center>" & rsCheck(2).Value & "</center>" & "</td>"
Response.write "<td>" & "<center>" & rsCheck(3).Value & "</center>" & "</td>"





Response.write "</tr>"
rsCheck.Movenext
Wend

Response.write "</table>"
end if
%>

<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<form name="form1" method="post" action="Management_SubjectCourse.asp?action=Add">
</p>
<table width="233" border="0" align="center">
<tr>
<td width="110">Subject Code:</td>
<td width="70">
<%
Set objConn = Server.CreateObject("ADODB.Connection")
Set rsCheck = Server.CreateObject("ADODB.Recordset")
sConnString = "Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("student.mdb") & ";" & _
"Persist Security Info = False"
objConn.Open(sConnString)

strSQL = "SELECT * FROM Subject"
rsCheck.Open strSQL, objConn
%>
<select name="selectSubjectCode">
<!-- <option value=""></option> -->
<%
do while not rscheck.EOF
%>
<option value="<%=rscheck("Subject_Code")%>"><%=rscheck("S ubject_Code")%></option>
<%
rscheck.movenext
loop
%>
</select></td>

<%
Set objConn = Server.CreateObject("ADODB.Connection")
Set rsCheck = Server.CreateObject("ADODB.Recordset")
sConnString = "Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("student.mdb") & ";" & _
"Persist Security Info = False"
objConn.Open(sConnString)

strSQL2 = "SELECT * FROM Subject where '" & request.Form("selectSubjectCode") & "'"
rsCheck.Open strSQL2, objConn


%>
<input name="txtCourseCode" type="hidden" value='<%=Request.Cookies("CourseCode")%>'/>
<br />



<td width="39">
<input type="submit" name="Submit" value="Add" />
</td>
<tr>
</table>
</form>
<%End If%>




<!------------------- start of add button click-->

<%IF Request.QueryString("action") = "Add" then%>

<% strSubjectCode=Request.form("selectSubjectCode")

Set objConn = Server.CreateObject("ADODB.Connection")
Set rsCheck = Server.CreateObject("ADODB.Recordset")
sConnString = "Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("student.mdb") & ";" & _
"Persist Security Info = False"
objConn.Open(sConnString)

strSQL2 = "SELECT * FROM Subject where Subject_Code ='" & strSubjectCode & "'"
rsCheck.Open strSQL2, objConn


%>




<%

Session("SubjectCode") = strSubjectCode
Response.Write(Session("SubjectCode"))
%>
<br>
<%
strSubjectName=rsCheck("Subject_Name")
Session("SubjectName") = strSubjectName
Response.Write(Session("SubjectName"))
%>
<input name="txtSubjectName" type="hidden" value='<%=RsCheck("Subject_Name")%>'/>
<%

%>
<br />
<%

' if strCourseCode = "" then
strCourseCode = request.form("txtCourseCode")
'
' response.Write("null CC")
' end if

%>



<%if strSubjectCode="" then%>
<p>
<center>
<table width="200" border="0">
<tr>
<td> <span style="font-weight: bold"> Subject Code is Blank</span></td>
</tr>
</table>
</p>
</center>

<%elseif strCourseCode="" then%>
<p>
<center>
<table width="200" border="0">
<tr>
<td> <span style="font-weight: bold"> strCourseCode is Null</span></td>
</tr>
</table>
</p>
</center>



<%

else
Set objConn = Server.CreateObject("ADODB.Connection")
Set rsCheck = Server.CreateObject("ADODB.Recordset")
sConnString = "Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("student.mdb") & ";" & _
"Persist Security Info = False"
objConn.Open(sConnString)


strSQL = "SELECT * FROM SubjectCourse where CourseCode = '" & strCourseCode & "' AND Subject_Code = '" & strSubjectCode & "'"
rsCheck.Open strSQL, objConn,1,3

if not rsCheck.RecordCount=0 then
%>

<p>
<center>
<table width="200" border="0">
<tr>
<td> <span style="font-weight: bold">Subject Code and Course Code Already Exist!</span></td>
</tr>
</table>
</p>
</center>


<%else



rsCheck.addnew
rsCheck.fields("CourseCode")= strCourseCode
rsCheck.fields("Subject_Code")= strSubjectCode
rsCheck.fields("Subject_Name")= strSubjectName
rsCheck.Update
rsCheck.close


%>

<p>
<center>
<table width="200" border="0">
<tr>
<td> <span style="font-weight: bold">Add Successful!</span></td>
</tr>
</table>
</p>
</center>
<%

%>
<!-- --><%end if%>




<%end if%>

<%End If%>
<%IF Request.QueryString("action") = "Delete" then%>


<%


strDeleteRecord = request.Cookies("DeleteCookies")
Response.Cookies("DeleteCookies").expires = now

if strDeleteRecord = "" then%>
<p>
<center>
<table width="200" border="0">
<tr>
<td> <span style="font-weight: bold">Please Select a Course</span></td>
</tr>
</table>
</p>
</center>
<%else
Set objConn = Server.CreateObject("ADODB.Connection")
Set rsCheck = Server.CreateObject("ADODB.Recordset")
sConnString = "Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("student.mdb") & ";" & _
"Persist Security Info = False"
objConn.Open(sConnString)




mysql = "Delete * from SubjectCourse WHERE Subject_Code='" & strDeleteRecord & "'"
set rsCheck=objConn.Execute(mysql)
%>




<p>
<center>
<table width="200" border="0">
<tr>
<td> <span style="font-weight: bold">Delete Successful!</span></td>
</tr>
</table>
</p>
</center>
<%End If%>
<%End If%>

</body>
</html>
Nov 11 '06 #1
1 1943
-----I want to modify the codes to this one but I got a wrong syntax----
"line 168"
<%Response.write "<td>" & "<center> <a href = Management_SubjectCourse.asp?action=" & =rsCheck(2).Value & "> DELETE</a> </center>" & "</td>"%>


----
in line"393"
<%IF Request.QueryString("action") = "rsCheck(2).Value" then%>

----------------Files--------------------------------------------------------------------------
MSaccess--- "student.mdb
Table name--- ""SubjectCourse"

Fields--Datatype:
"SubjectCourse" -- "AutoNumber"
"CourseCode" -- "Text"
"Subject_Code" -- "Text"
"Subject_Name" -- "Text"

ASP Name = "Management_SubjectCourse.asp"
Nov 11 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dynamo | last post by:
Hello again ;-) What is the correct syntax to use when inserting a value into a table that contains a variable name with spaces. This works $query = "INSERT INTO Catalogue (Author) VALUES...
2
by: Tim | last post by:
In an ASP web page I am trying to calculate a value in seconds from two date and times. Can anyone help me find the correct syntax to make this work?!?! (This code below work correctly)...
0
by: Alistair | last post by:
hello again people... Access2000, IIS6, win XP pro I have a form where users can enter search criteria for various products. now, if this form has 2 fields, colour and size (it wil have more...
1
by: Oplec | last post by:
Hi, I'm learning C++ as a hobby using The C++ Programming Language : Special Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that deal with templates. Exercise 13.9 asks for me...
7
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double...
3
by: martinharvey | last post by:
This is probably a very simple question but i would appreciate some help with the correct syntax for and update stored procedure I have created a user form that allows the user to update the...
2
by: MLH | last post by:
SendMailPlusWithOE Subject, Message, Recipients, Files, "08" I've seen the above syntax used to call the sub SendMailPlusWithOE Is it correct/incorrect/good practice/bad practice or just a...
5
by: sam | last post by:
Why the folowing code generates ans error in the select expression ?: DataRow drRows = dsRevues.Tables.Select("year >= '2000' && year <= '2007'");// What is the correct syntax ? Sam
2
by: Andy Champ | last post by:
We have a class with something that, simplified, looks like this: template <typename Tclass foo { T beyondAllReaching; // In VC2005, this works OK template <typename Ufriend void...
3
by: VikR | last post by:
I'm seeking to use Select AS. Here's my query: select * from new_alloys_added_by_users left join ratings_for_fz_scores on new_alloys_added_by_users.Alloy_ID_No =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.