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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a new row

Status
Not open for further replies.

malola123

Technical User
Feb 16, 2007
17
CA
Hi,

I have created a web page where a table from the SQL database is outputted onto the screen. I also created another page that allows the users to add or delete another row to the table. After providing the necessary links between these two pages, I check to see whether the second page functions properly. However, it shos an error stating:

Expected 'End'
/admin/sections/new/modify_activity_type.asp, line 90

Im not too sure what is meant by this, or maybe im misunderstanding something.

Can someone please clarify with me?...Thx

Here is the code :

"
function confirmDelete() {

}

function limitText(limitField, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
}
}

</script>
</head>
<%
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open = ConnectionString("IS")

id = Request.QueryString("id")
UPDATE = Request.QueryString("UPDATE")

If UPDATE = "ON" Then

SubmitButton = Request.QueryString("SubmitButton")

If SubmitButton = "Delete" Then
stmt = "DELETE From T_C_Activity_Types Where id = "& id

oConn.Execute(stmt)

Response.Write "Record Deleted"

Response.End
End If

if id <> "" Then
stmt = "SELECT * FROM T_C_Activity_Types ORDER BY ActivityType"

oRs = oConn.Execute(stmt)


tempID = Trim(oRs("id"))
tempActivityType = Trim(oRs("ActivityType"))

If oRs("id") = "1" Then
tempID = "Checked"
Else
tempID = ""
End If

If oRs("ActivityType") = "1" Then
tempActivityType = "Checked"
Else
tempActivityType = ""
End If

end if

stmt = "Select id, name from T_C_Activity_Types where id = 1"
Set oRs = oConn.Execute(stmt)

%>

<body style="margin:0px" onUnLoad="window.opener.location.reload()">
<form name="form1" action="modify_activity_type.asp" method="get">
<table style="width:100%">

<th colspan=3><input class="mainButton" type="submit" value="Submit" name="SubmitButton">
<input type="hidden" value="ON" name="UPDATE">
<%
If id <> "" Then
Response.Write "<input class=""mainButton"" type=""submit"" value=""Delete"" name=""SubmitButton"" onclick=""return confirm('Are you sure you want to delete this user?')"">"
End If

%>
<input type="hidden" value="<%= id %>" name="id"> // This is line 90!

 
If SubmitButton = "Delete" Then
stmt = "DELETE From T_C_Activity_Types Where id = "& id

Should be on one line or add "end if" after it.
 
Hi,

Ye i changed that and I updated some of the other code, but I am not able to send the request through properly. Get this error message:

Incorrect syntax near the keyword 'Values'.
/admin/sections/new/modify_activity_type.asp, line 68

"

If UPDATE = "ON" Then

SubmitButton = Request.QueryString("SubmitButton")

If SubmitButton = "Delete" Then
stmt = "DELETE From T_C_Activity_Types Where id = "& id

oConn.Execute(stmt)

Response.Write "Record Deleted"

Else


txtID = Request.QueryString("txtID")
txtActivityType = Request.QueryString("txtActivityType")


If id = "" Then
stmt = "INSERT Into T_C_Activity_Types ("&_
"id, "&_
"ActivityType, "&_
"Values ("&_ //problem here
"'"& txtID &"', "&_
"'"& txtActivityType &"')"

Else
stmt = "UPDATE T_C_Activity_Types Set "&_
"id = '"& txtID &"', "&_
"ActivityType = '"& txtActivityType &"', "&_
"Where id = "& id
End If
oConn.Execute(stmt)

Response.Write "Record Updated"
End If


Response.End
End If

". Thx again
 
ActivityType[!])[/!] "&_

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi...this answer did help, but im still getting an error:

now the error says:

Cannot insert explicit value for identity column in table 'T_C_Activity_Types' when IDENTITY_INSERT is set to OFF.
/admin/sections/new/modify_activity_type.asp, line 68

"

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open = ConnectionString("IS")

id = Request.QueryString("id")
UPDATE = Request.QueryString("UPDATE")

If UPDATE = "ON" Then

SubmitButton = Request.QueryString("SubmitButton")

If SubmitButton = "Delete" Then
stmt = "DELETE From T_C_Activity_Types Where id = "& id

oConn.Execute(stmt)

Response.Write "Record Deleted"

Else


txtID = Request.QueryString("txtID")
txtActivityType = Request.QueryString("txtActivityType")


If id = "" Then
stmt = "INSERT Into T_C_Activity_Types ("&_
"id, "&_
"ActivityType) "&_
"Values ("&_
"'"& txtID &"', "&_
"'"& txtActivityType &"')"

Else
stmt = "UPDATE T_C_Activity_Types Set "&_
"id = '"& txtID &"', "&_
"ActivityType = '"& txtActivityType &"', "&_
"Where id = "& id
End If
oConn.Execute(stmt) //problem with execution with the statement.

thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top