M
monika
hi...
when I try to insert a duplicate record I get the primary key error. which
is good. but I want to generate a user friendly error ... telling the user
that u have got this error because u r trying to insert a duplicate record.
i can simply do so by using "on error resume next"....
this is what I do:
"on error resume next
server.transfer("error.asp")"
the problem is it simply takes me to a page where I display an error has
occurred... it doesn't look attractive to display a one line error in a big
page? I hope I am clear....
1. how can I display the error message in my error.asp
2. I can I make it look better... how is error handling done ???
I am a newbie and would appreciate if anyone can give me some examples,.
thanks
<%
on error resume next
server.transfer("error.asp")
%>
<html>
<head>
<title>sdad</title>
</head>
<body>
<table><tr><td bgcolor="SILVER">
<BIG> <B> <FONT COLOR="#000080"> <%=session("TxtName")%> your story is
submitted!!!
&nbs
p;
Today is <%=DATE()%></b></td><p></p></tr>
</table><p></p>
<%
Dim strStoryContent
DIM RSA
DIM QUERY1
DIM Conn
dim adCmdText
dim currentdate
'for debug
'For Each Item in Request.Form
'Response.Write(Item & " = " & Request.Form(Item) & "<br>")
'Next
adCmdText = 1
'create and open database connection
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "dsn=school"
'create commad object
set objCmd = server.createobject("adodb.command")
currentDate = date()
strStoryContent = Request.form("mytextarea")
If Request.form("submit") <> "" then
If Request("mytextarea")<>"" then
Set RSA = Server.CreateObject("ADODB.Recordset")
QUERY1 = "INSERT INTO student_content
(student_id,story_id,status_student,story_original,story_status_date,story_w
ord_count) VALUES
("&session("loggedID")&","&session("selectStoryID")&",'"&Request.form("Submi
t")&"','"&strStoryContent&"','"¤tDate&"',"&request.form("wordsCount")&
")"
set objCmd.ActiveConnection = Conn
objCmd.CommandText = Query1
objCmd.CommandType = adCmdText
'execute the command
objCmd.Execute
else
response.write "You have not written the story?"
End If
end if
'close and dereference database objects
set objCmd = nothing
conn.close
set conn = nothing
%>
</body>
</html>
when I try to insert a duplicate record I get the primary key error. which
is good. but I want to generate a user friendly error ... telling the user
that u have got this error because u r trying to insert a duplicate record.
i can simply do so by using "on error resume next"....
this is what I do:
"on error resume next
server.transfer("error.asp")"
the problem is it simply takes me to a page where I display an error has
occurred... it doesn't look attractive to display a one line error in a big
page? I hope I am clear....
1. how can I display the error message in my error.asp
2. I can I make it look better... how is error handling done ???
I am a newbie and would appreciate if anyone can give me some examples,.
thanks
<%
on error resume next
server.transfer("error.asp")
%>
<html>
<head>
<title>sdad</title>
</head>
<body>
<table><tr><td bgcolor="SILVER">
<BIG> <B> <FONT COLOR="#000080"> <%=session("TxtName")%> your story is
submitted!!!
&nbs
p;
Today is <%=DATE()%></b></td><p></p></tr>
</table><p></p>
<%
Dim strStoryContent
DIM RSA
DIM QUERY1
DIM Conn
dim adCmdText
dim currentdate
'for debug
'For Each Item in Request.Form
'Response.Write(Item & " = " & Request.Form(Item) & "<br>")
'Next
adCmdText = 1
'create and open database connection
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "dsn=school"
'create commad object
set objCmd = server.createobject("adodb.command")
currentDate = date()
strStoryContent = Request.form("mytextarea")
If Request.form("submit") <> "" then
If Request("mytextarea")<>"" then
Set RSA = Server.CreateObject("ADODB.Recordset")
QUERY1 = "INSERT INTO student_content
(student_id,story_id,status_student,story_original,story_status_date,story_w
ord_count) VALUES
("&session("loggedID")&","&session("selectStoryID")&",'"&Request.form("Submi
t")&"','"&strStoryContent&"','"¤tDate&"',"&request.form("wordsCount")&
")"
set objCmd.ActiveConnection = Conn
objCmd.CommandText = Query1
objCmd.CommandType = adCmdText
'execute the command
objCmd.Execute
else
response.write "You have not written the story?"
End If
end if
'close and dereference database objects
set objCmd = nothing
conn.close
set conn = nothing
%>
</body>
</html>