I am using ASP with Oracle 9i
When I try to save data by clicking save button, it gives following error.
Variable is undefined 'adModeReadWrite'
where as adModeReadWrite is an keyword. The error may in the line 42
What should be the problem. -
<%@ Language=VBScript%>
-
<%Option Explicit%>
-
<html>
-
<head>
-
<title>Barauni Refinery - Post Retirement Data Management</title>
-
</head>
-
<body>
-
<%
-
Dim R
-
Dim R1
-
Dim vcategory, vgrade, vamount
-
Dim errorMsg
-
Dim conn
-
Dim i
-
Set conn = Server.Createobject("ADODB.Connection")
-
conn.Open "DSN=ORA; User ID = scott; Password = tiger"
-
Set R = Server.CreateObject("ADODB.Recordset")
-
Set R1 = Server.CreateObject("ADODB.Recordset")
-
If Not IsEmpty(Request.Form("submit")) then
-
vcategory = Request.Form("vcategory")
-
vgrade = Request.Form("vgrade")
-
vamount = Request.Form("amount")
-
If len(vcategory) = 0 then
-
errorMsg = "You must enter category."
-
End If
-
If len(errorMsg) = 0 Then
-
If len(vgrade) = 0 Then
-
errorMsg = "Your must enter grade."
-
Elseif len(vgrade) > 10 Then
-
errorMsg = "The employee grade > 10 characters. Please reduce the size."
-
Else
-
For i = 1 to len(vgrade)
-
If instr(1, "_/()[]{}abcdefghijklmnopqrstuvwxyz0123456789 ", mid(vgrade, i, 1), vbTextCompare) = 0 then
-
errorMsg = "The employee grade you entered is invalid. Please re-enter this field."
-
Exit For
-
End If
-
Next
-
End If
-
End If
-
If len(errorMsg) = 0 Then
-
conn.Close
-
conn.Mode = adModeReadWrite
-
conn.Open
-
R.Open "Select * from grademst", conn, adOpenStatic, adLockOptimistic, adCmdText
-
R.Addnew
-
R("category") = vcategory
-
R("grade") = vgrade
-
R("amount") = vamount
-
R.UPdate
-
R.Close
-
End If
-
End If
-
%>
-
<div style="Position:Absolute; top:120; left:50; background-color: #f0f0f0">
-
<h2>SABF Entry</h3>
-
<hr>
-
<p>
-
<form method="POST" action="grade.asp">
-
<%
-
If len(errorMsg) > 0 Then
-
Response.Write "<p><font color='red'>" & errorMsg & "</font></p>"
-
End If
-
%>
-
<table width=900>
-
<tr>
-
<table align="center">
-
<tr>
-
<td align="center"><font face="arial"><h3>Employee Grading Master</h3></font></h3>
-
</tr>
-
</table>
-
</tr>
-
<tr>
-
<table align="center">
-
<tr>
-
<td align="right"><font face="arial" size=2>Grade : </font></td>
-
<td align='left'>
-
<select name="vgrade">
-
<option value="I" selected>I</option>
-
<option value="II">II</option>
-
<option value="III">III</option>
-
<option value="IV">IV</option>
-
</select>
-
</td>
-
</tr>
-
-
<tr>
-
<td align="right"><font face="arial" size=2>Category : </font></td>
-
<td align='left'>
-
<select name="vcategory">
-
<option value="Officer">Officer</option>
-
<option value="staff" selected>Staff</option></select>
-
</select>
-
</td>
-
</tr>
-
-
<tr>
-
<td align="right"><font face="arial" size=2>Amount : </font></td>
-
<td align='left'><input type="text" style="width:100px" name="vamount"></td>
-
</tr>
-
-
</table>
-
<tr>
-
<table align="center">
-
<tr>
-
<td align="center"><input type="Submit" name="submit" value="Save">
-
<input type="reset" name="reset" value="Reset">
-
</td>
-
</tr>
-
</table>
-
</tr>
-
</table>
-
</form>
-
</p>
-
</div>
-
-
</body>
-
</html>
-
Hello vikas251074,
You are entering into a common problem in web development. When you hit the “refresh” button on a web browser; in all reality you are “re-doing” the page. So if you came to the page from a post then the post gets “refresh”ed too.
Just remember: the browser “refresh” button will repost anything that got posted to the page before.
There are a many workarounds that you can do to help you as a developer to stop double posts due to the browser “refresh” button. Here is one (uses two pages):
FormPage.asp -
<html>
-
<head>
-
<title>FormPage.asp</title>
-
</head>
-
<body>
-
<p>
-
<%
-
Select Case Request("Error")
-
Case "0"
-
Response.Write("Update done.")
-
Case "1"
-
Response.Write("No update was done.")
-
End Select
-
%>
-
</p>
-
<form name="xForm" method="post" action="PostPage.asp">
-
Amount: <input type="text" name="vamount">
-
<br />
-
<input type="Submit" name="submit" value="Save">
-
</form>
-
</body>
-
</html>
-
PostPage.asp -
<%
-
Response.CacheControl = "no-cache"
-
Response.AddHeader "Pragma", "no-cache"
-
Response.Expires = -1
-
-
Set Conn = Server.CreateObject("ADODB.Connection")
-
Conn.Open("DSN=dsn_ois;UID=scott;PWD=tiger;"))
-
-
On Error Resume Next
-
SQL = "INSERT INTO grademst (category, grade, amount) VALUES('Officer', 'II', '1')"
-
Conn.Execute SQL
-
-
If Err <> 0 Then
-
Response.Redirect("FormPage.asp?Error=1")
-
Else
-
Response.Redirect("FormPage.asp?Error=0")
-
End If
-
%>
-
Hope this helps,
CroCrew~
8 4630
Hello vikas251074,
I am looking at you VB code now and will try to post an answer to your question soon. For now I did look at the HTML part of your code and your <tags> are in bad need of help. You have nested <tags> where they should not be. Bad HTML could change the resulting display in ways that you might not want and could lead into thinking other parts of your code could be the culprit.
CroCrew~
Hello vikas251074,
Ok, let try to make this simple. Try this:
Hope this helps,
CroCrew~
adModeReadWrite, for your future reference, is a constant, it should be set to some integer, probably between 0 and 5. Most tutorials that say to use that, also say to include a text file (via server-side include) named "adodb.inc" that includes a huge list of constants. You should also be able to google it to find the correct value.
Jared
Thankyou sir
It indeed helps me a lot.
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open("DSN=dsn_ois;UID=scott;PWD=tiger;"))
SQL = "INSERT INTO grademst (category, grade, amount) VALUES('" & vcategory & "', '" & vgrade & "', '" & vamount & "')"
Conn.Execute SQL
To display the the data from oracle table
I need to use recordset
I am using the following way
Set R = Server.CreateObject("ADODB.Recordset")
Set R = conn.Open SQL
This is not a correct syntax for opening recordset, it is giving error
After googling a lot, I find the following suggestion
R = conn.execute (SQL)
but it is wrong. Then i use
R = conn.open (SQL)
still it is wrong. then what should i use there.
Hello vikas251074,
The query that you’re using does not return data from the database. A “SELECT” query would return data. Below is an example to return data: -
Set Conn = Server.CreateObject("ADODB.Connection")
-
Conn.Open("DSN=dsn_ois;UID=scott;PWD=tiger;")
-
-
Set rs = Server.CreateObject("ADODB.Recordset")
-
SQL = "SELECT category, grade, amount FROM grademst"
-
rs.Open SQL, Conn
-
-
Do Until (rs.EOF)
-
Response.Write("Category: " &rs("category").value & " ")
-
Response.Write("Grade: " &rs("grade").value & " ")
-
Response.Write("Amount: " &rs("amount").value)
-
Response.Write("<br /> <br />")
-
rs.MoveNext
-
Loop
-
Hope this helps,
CroCrew~
When I enter one record and click on save button, then it is saved
then when I just refreshed the page then again the same data is saved
This is quite alarming situation.
This can be controlled by following ways -
1) I should kill the value just after saving record
2) Restrick the duplicate entry of data.
I think first one may be very successful and logical.
What should I do and how ? ..
Hello vikas251074,
You are entering into a common problem in web development. When you hit the “refresh” button on a web browser; in all reality you are “re-doing” the page. So if you came to the page from a post then the post gets “refresh”ed too.
Just remember: the browser “refresh” button will repost anything that got posted to the page before.
There are a many workarounds that you can do to help you as a developer to stop double posts due to the browser “refresh” button. Here is one (uses two pages):
FormPage.asp -
<html>
-
<head>
-
<title>FormPage.asp</title>
-
</head>
-
<body>
-
<p>
-
<%
-
Select Case Request("Error")
-
Case "0"
-
Response.Write("Update done.")
-
Case "1"
-
Response.Write("No update was done.")
-
End Select
-
%>
-
</p>
-
<form name="xForm" method="post" action="PostPage.asp">
-
Amount: <input type="text" name="vamount">
-
<br />
-
<input type="Submit" name="submit" value="Save">
-
</form>
-
</body>
-
</html>
-
PostPage.asp -
<%
-
Response.CacheControl = "no-cache"
-
Response.AddHeader "Pragma", "no-cache"
-
Response.Expires = -1
-
-
Set Conn = Server.CreateObject("ADODB.Connection")
-
Conn.Open("DSN=dsn_ois;UID=scott;PWD=tiger;"))
-
-
On Error Resume Next
-
SQL = "INSERT INTO grademst (category, grade, amount) VALUES('Officer', 'II', '1')"
-
Conn.Execute SQL
-
-
If Err <> 0 Then
-
Response.Redirect("FormPage.asp?Error=1")
-
Else
-
Response.Redirect("FormPage.asp?Error=0")
-
End If
-
%>
-
Hope this helps,
CroCrew~
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dan Finn |
last post by:
OpenBSD 3.2
Apache 1.3.26
PHP 4.3.4
PHP-Nuke 6.9
getting these in the apache error log:
Sun Nov 16 20:20:16 2003] PHP Notice: Undefined variable:
HTTP_USER_AGENT in...
|
by: os2 |
last post by:
hi
in bd.php i do:
<?php
$serveur = "localhost";
$utilisateur = "root";
$motDePasse = "";
$base = "laboiteaprog";
|
by: Sharon |
last post by:
Hi! Does anyone know why the onclick in the following popup menu gives
the error:"Val is undefined"? Does it have something to do with the
fact that it is called within the variable tablePop?...
|
by: Chris Beall |
last post by:
If you want your code to be bulletproof, do you have to explicitly check
for the existence of any possibly-undefined variable?
Example: window.outerHeight is defined by some browsers, but not...
|
by: sneill |
last post by:
How is it possible to take the value of a variable (in this case,
MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name?
In the following example I want 'oIcon' object to have...
|
by: Sourav |
last post by:
Suppose I have a code like this,
#include <stdio.h>
int *p;
void foo(int);
int main(void){
foo(3);
printf("%p %d\n",p,*p);
|
by: onkar |
last post by:
Given the following code & variable i .
int main(int argc,char **argv){
int i;
printf("%d\n",i);
return 0;
}
here i is allocated from bss or stack ?
|
by: pbmods |
last post by:
VARIABLE SCOPE IN JAVASCRIPT
LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN )
PREREQS: VARIABLES
First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause...
|
by: Bob Bruyn |
last post by:
I've recently installed Apache 2 and php 5.2 on my WIndows XP
machine. Everything is up and running.
I'm passing some vars via the URL. It works fine online:...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |