473,809 Members | 2,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can any one help me to correct my syntax?

3 New Member
----------------------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="VB SCRIPT" 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.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitl ed Document</title>
</head>

<body>
<H3 align="center"> Subject Specification per Course</H3>
<%strCourseCo de = request.form("t xtCourseCode")% >
<%
Session("Course Code") = strCourseCode
'Response.Write (Session("Cours eCode"))
'Session.Conten ts.Remove("Cour seCode")
%>


<form name="form1" method="post" action="Managem ent_SubjectCour se.asp?action=V iew">
</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.CreateOb ject("ADODB.Con nection")
Set rsCheck = Server.CreateOb ject("ADODB.Rec ordset")
sConnString = "Provider = Microsoft.Jet.O LEDB.4.0;" & _
"Data Source=" & Server.MapPath( "student.md b") & ";" & _
"Persist Security Info = False"
objConn.Open(sC onnString)

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

<%If strCourseCode = "" then%>


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




<option value ="<%=request.fo rm("txtCourseCo de")%>" selected="selec ted"> <%response.writ e(request.form( "txtCourseCode" ))%></option>
<!--
<option value ="" selected="selec ted"></option>
-->
<%Session.Conte nts.Remove("Cou rseCode")%>
<%end if%>
<%
do while not rscheck.EOF
%>

<option value="<%=rsche ck("CourseCode" )%>"><%=rscheck ("CourseCode")% ></option>
<%
rscheck.movenex t
loop
%>
</select>
</td>
</tr>

<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="View" /></td>
</tr>
</table>
</form>
<%'Response.Wri te Request.Cookies ("Cookies")% >
<%'Response.Coo kies("Cookies") .expires = now%>
<!--<!--<!-- -->
<%IF Request.QuerySt ring("action") = "View" then%>
<br />
<%
if strCourseCode = "" then
strCourseCode=R equest.form("se lectCourseCode" )
else
strCourseCode = request.form("t xtCourseCode")
end if
Response.Cookie s("Cookies") = strCourseCode
Response.Cookie s("CourseCode ") = strCourseCode
%>


<table align="center">


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

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

<%






Set Conn = Server.CreateOb ject("ADODB.Con nection")
sConnection = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & Server.MapPath( "student.md b") & ";" & _
"Persist Security Info=True"
Conn.Open(sConn ection)


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

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_Subj ectCourse.asp?a ction=Delete> DELETE</a> </center>" & "</td>"
Response.cookie s("DeleteCookie s") = rsCheck(2).Valu e
%>
<!--<input name="txtDelete " type="hidden" value='<%'=rsCh eck(0)%>'/> -->
<%

'

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





Response.write "</tr>"
rsCheck.Movenex t
Wend

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

<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<!-- -->
<form name="form1" method="post" action="Managem ent_SubjectCour se.asp?action=A dd">
</p>
<table width="233" border="0" align="center">
<tr>
<td width="110">Sub ject Code:</td>
<td width="70">
<%
Set objConn = Server.CreateOb ject("ADODB.Con nection")
Set rsCheck = Server.CreateOb ject("ADODB.Rec ordset")
sConnString = "Provider = Microsoft.Jet.O LEDB.4.0;" & _
"Data Source=" & Server.MapPath( "student.md b") & ";" & _
"Persist Security Info = False"
objConn.Open(sC onnString)

strSQL = "SELECT * FROM Subject"
rsCheck.Open strSQL, objConn
%>
<select name="selectSub jectCode">
<!-- <option value=""></option> -->
<%
do while not rscheck.EOF
%>
<option value="<%=rsche ck("Subject_Cod e")%>"><%=rsche ck("Subject_Cod e")%></option>
<%
rscheck.movenex t
loop
%>
</select></td>

<%
Set objConn = Server.CreateOb ject("ADODB.Con nection")
Set rsCheck = Server.CreateOb ject("ADODB.Rec ordset")
sConnString = "Provider = Microsoft.Jet.O LEDB.4.0;" & _
"Data Source=" & Server.MapPath( "student.md b") & ";" & _
"Persist Security Info = False"
objConn.Open(sC onnString)

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


%>
<input name="txtCourse Code" type="hidden" value='<%=Reque st.Cookies("Cou rseCode")%>'/>
<br />



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




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

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

<% strSubjectCode= Request.form("s electSubjectCod e")

Set objConn = Server.CreateOb ject("ADODB.Con nection")
Set rsCheck = Server.CreateOb ject("ADODB.Rec ordset")
sConnString = "Provider = Microsoft.Jet.O LEDB.4.0;" & _
"Data Source=" & Server.MapPath( "student.md b") & ";" & _
"Persist Security Info = False"
objConn.Open(sC onnString)

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


%>




<%

Session("Subjec tCode") = strSubjectCode
Response.Write( Session("Subjec tCode"))
%>
<br>
<%
strSubjectName= rsCheck("Subjec t_Name")
Session("Subjec tName") = strSubjectName
Response.Write( Session("Subjec tName"))
%>
<input name="txtSubjec tName" type="hidden" value='<%=RsChe ck("Subject_Nam e")%>'/>
<%

%>
<br />
<%

' if strCourseCode = "" then
strCourseCode = request.form("t xtCourseCode")
'
' 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.CreateOb ject("ADODB.Con nection")
Set rsCheck = Server.CreateOb ject("ADODB.Rec ordset")
sConnString = "Provider = Microsoft.Jet.O LEDB.4.0;" & _
"Data Source=" & Server.MapPath( "student.md b") & ";" & _
"Persist Security Info = False"
objConn.Open(sC onnString)


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

if not rsCheck.RecordC ount=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.QuerySt ring("action") = "Delete" then%>


<%


strDeleteRecord = request.Cookies ("DeleteCookies ")
Response.Cookie s("DeleteCookie s").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.CreateOb ject("ADODB.Con nection")
Set rsCheck = Server.CreateOb ject("ADODB.Rec ordset")
sConnString = "Provider = Microsoft.Jet.O LEDB.4.0;" & _
"Data Source=" & Server.MapPath( "student.md b") & ";" & _
"Persist Security Info = False"
objConn.Open(sC onnString)




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 1971
terryspanky
3 New Member
-----I want to modify the codes to this one but I got a wrong syntax----
"line 168"
<%Response.writ e "<td>" & "<center> <a href = Management_Subj ectCourse.asp?a ction=" & =rsCheck(2).Val ue & "> DELETE</a> </center>" & "</td>"%>


----
in line"393"
<%IF Request.QuerySt ring("action") = "rsCheck(2).Val ue" then%>

----------------Files--------------------------------------------------------------------------
MSaccess--- "student.md b
Table name--- ""SubjectCourse "

Fields--Datatype:
"SubjectCou rse" -- "AutoNumber "
"CourseCode " -- "Text"
"Subject_Co de" -- "Text"
"Subject_Na me" -- "Text"

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

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

Similar topics

5
2405
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 ('Stephen King')" And this does not
2
2093
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) DetectionTime=#7/30/03 10:36:45 AM# MyTime=#7/30/03 10:36:45 PM# TTClose=(MyTime)-(DetectionTime) TTTClose=(((TTClose*24)*60)*60)
0
1411
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 but I'm assuming the the principle for two fields will be the same for ten fields) what would be the correct syntax for performing a query where the user
1
3347
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 to turn a previously made String class that deals with char's into a templated String class that uses the template parameter C instead of char. I thought it would be fairly simple to do this exercise, but I encoutered many errors for my...
7
6682
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 checked, and the insert works fine (tried to use it from access)... im using visual C# express 2k5... what could be wrong? thanks!
3
1579
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 name and address fields in a datatable called customers based on the input value customer ID = ( datatable/Customers)customerID I have got this far and then got lost: Create SP_UpdateCustomer
2
1343
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 matter of personal preference?
5
3897
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
1696
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 method(foo<Tl, foo<Ur); // But VC2008 requires this
3
3291
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 = ratings_for_fz_scores.Alloy_ID_No AS NewAlloysAndRatings I get this error message: How can I correct this?
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10391
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10121
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.