473,395 Members | 1,872 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,395 software developers and data experts.

Variable is undefined 'adModeReadWrite'

vikas251074
198 100+
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.

Expand|Select|Wrap|Line Numbers
  1. <%@ Language=VBScript%>
  2. <%Option Explicit%>
  3. <html>
  4. <head>
  5. <title>Barauni Refinery - Post Retirement Data Management</title>
  6. </head>
  7. <body>
  8. <%
  9. Dim R
  10. Dim R1 
  11. Dim vcategory, vgrade, vamount
  12. Dim errorMsg
  13. Dim conn
  14. Dim i
  15. Set conn = Server.Createobject("ADODB.Connection")
  16. conn.Open "DSN=ORA; User ID = scott; Password = tiger"
  17. Set R = Server.CreateObject("ADODB.Recordset")
  18. Set R1 = Server.CreateObject("ADODB.Recordset")
  19.   If Not IsEmpty(Request.Form("submit")) then
  20.     vcategory = Request.Form("vcategory")
  21.     vgrade = Request.Form("vgrade")
  22.     vamount = Request.Form("amount")
  23.     If len(vcategory) = 0 then
  24.       errorMsg = "You must enter category."
  25.     End If
  26.     If len(errorMsg) = 0 Then
  27.       If len(vgrade) = 0 Then
  28.         errorMsg = "Your must enter grade."
  29.       Elseif len(vgrade) > 10 Then
  30.         errorMsg = "The employee grade > 10 characters. Please reduce the size."
  31.       Else
  32.         For i = 1 to len(vgrade)
  33.           If instr(1, "_/()[]{}abcdefghijklmnopqrstuvwxyz0123456789 ", mid(vgrade, i, 1), vbTextCompare) = 0 then
  34.             errorMsg = "The employee grade you entered is invalid. Please re-enter this field."
  35.             Exit For
  36.           End If
  37.         Next
  38.       End If
  39.     End If
  40.     If len(errorMsg) = 0 Then
  41.       conn.Close
  42.       conn.Mode = adModeReadWrite
  43.       conn.Open
  44.       R.Open "Select * from grademst", conn, adOpenStatic, adLockOptimistic, adCmdText
  45.       R.Addnew
  46.       R("category") = vcategory
  47.       R("grade") = vgrade
  48.       R("amount") = vamount
  49.       R.UPdate
  50.       R.Close
  51.     End If
  52.   End If
  53. %>
  54.   <div style="Position:Absolute; top:120; left:50; background-color: #f0f0f0">
  55.     <h2>SABF Entry</h3>
  56.     <hr>
  57.     <p>
  58.     <form method="POST" action="grade.asp">
  59. <%
  60.       If len(errorMsg) > 0 Then
  61.         Response.Write "<p><font color='red'>" & errorMsg & "</font></p>"
  62.       End If
  63. %>
  64.       <table width=900>
  65.         <tr>
  66.           <table align="center">
  67.             <tr>
  68.               <td align="center"><font face="arial"><h3>Employee Grading Master</h3></font></h3>
  69.             </tr>
  70.           </table>
  71.         </tr>
  72.         <tr>
  73.           <table align="center">
  74.             <tr>
  75.               <td align="right"><font face="arial" size=2>Grade : </font></td>
  76.               <td align='left'>
  77.                 <select name="vgrade">
  78.                        <option value="I" selected>I</option>
  79.                        <option value="II">II</option>
  80.                        <option value="III">III</option>
  81.                        <option value="IV">IV</option>
  82.                 </select>
  83.               </td>
  84.             </tr>
  85.  
  86.             <tr>
  87.               <td align="right"><font face="arial" size=2>Category : </font></td>
  88.               <td align='left'>
  89.                 <select name="vcategory">
  90.                        <option value="Officer">Officer</option>
  91.                        <option value="staff" selected>Staff</option></select>
  92.                 </select>
  93.               </td>
  94.             </tr>
  95.  
  96.             <tr>
  97.               <td align="right"><font face="arial" size=2>Amount : </font></td>
  98.               <td align='left'><input type="text" style="width:100px" name="vamount"></td>
  99.             </tr>
  100.  
  101.           </table> 
  102.         <tr>
  103.           <table align="center">
  104.             <tr>
  105.               <td align="center"><input type="Submit" name="submit" value="Save">
  106.                                  <input type="reset" name="reset" value="Reset">
  107.               </td>
  108.             </tr>
  109.           </table>
  110.         </tr>
  111.       </table>
  112.     </form>
  113.     </p>
  114.   </div>
  115.  
  116. </body>
  117. </html>
  118.  
Oct 12 '09 #1

✓ answered by CroCrew

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
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <title>FormPage.asp</title>
  4.     </head>
  5.     <body>
  6.         <p>
  7.             <%
  8.                 Select Case Request("Error")
  9.                     Case "0"
  10.                         Response.Write("Update done.")
  11.                     Case "1"
  12.                         Response.Write("No update was done.")
  13.                 End Select
  14.             %>
  15.         </p>
  16.         <form name="xForm" method="post" action="PostPage.asp">
  17.             Amount: <input type="text" name="vamount">
  18.             <br />
  19.             <input type="Submit" name="submit" value="Save">
  20.         </form>
  21.     </body>
  22. </html>
  23.  
PostPage.asp
Expand|Select|Wrap|Line Numbers
  1. <%
  2.     Response.CacheControl = "no-cache"
  3.     Response.AddHeader "Pragma", "no-cache"
  4.     Response.Expires = -1
  5.  
  6.     Set Conn = Server.CreateObject("ADODB.Connection")  
  7.         Conn.Open("DSN=dsn_ois;UID=scott;PWD=tiger;")) 
  8.  
  9.         On Error Resume Next 
  10.             SQL = "INSERT INTO grademst (category, grade, amount) VALUES('Officer', 'II', '1')" 
  11.             Conn.Execute SQL 
  12.  
  13.             If Err <> 0 Then 
  14.                 Response.Redirect("FormPage.asp?Error=1")
  15.             Else
  16.                 Response.Redirect("FormPage.asp?Error=0")
  17.             End If
  18. %>
  19.  
Hope this helps,
CroCrew~

8 4630
CroCrew
564 Expert 512MB
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~
Oct 12 '09 #2
CroCrew
564 Expert 512MB
Hello vikas251074,

Ok, let try to make this simple. Try this:

Expand|Select|Wrap|Line Numbers
  1. <% 
  2.     If Not IsEmpty(Request.Form("submit")) then 
  3.         vcategory = Request.Form("vcategory") 
  4.         vgrade = Request.Form("vgrade") 
  5.         vamount = Request.Form("amount") 
  6.         If len(vcategory) = 0 then 
  7.             errorMsg = "You must enter category." 
  8.         End If 
  9.         If len(errorMsg) = 0 Then 
  10.             If len(vgrade) = 0 Then 
  11.                 errorMsg = "Your must enter grade." 
  12.             Elseif len(vgrade) > 10 Then 
  13.                 errorMsg = "The employee grade > 10 characters. Please reduce the size." 
  14.             Else 
  15.                 For i = 1 to len(vgrade) 
  16.                     If instr(1, "_/()[]{}abcdefghijklmnopqrstuvwxyz0123456789 ", mid(vgrade, i, 1), vbTextCompare) = 0 then 
  17.                         errorMsg = "The employee grade you entered is invalid. Please re-enter this field." 
  18.                         Exit For 
  19.                     End If 
  20.                 Next 
  21.             End If 
  22.         End If 
  23.         If len(errorMsg) = 0 Then 
  24.             Set Conn = Server.CreateObject("ADODB.Connection") 
  25.                 Conn.Open("DSN=dsn_ois;UID=scott;PWD=tiger;"))
  26.  
  27.                 SQL = "INSERT INTO grademst (category, grade, amount) VALUES('" & vcategory & "', '" & vgrade & "', '" & vamount & "')"
  28.                 Conn.Execute SQL
  29.         End If 
  30.     End If 
  31. %> 
  32.  
  33. <html> 
  34.     <head> 
  35.         <title></title> 
  36.     </head> 
  37.     <body> 
  38.         <div style="Position:Absolute; top:120; left:50; background-color: #f0f0f0"> 
  39.             <h2>SABF Entry</h3> 
  40.             <hr> 
  41.             <p> 
  42.                 <form method="POST" action="grade.asp"> 
  43.                     <% 
  44.                         If len(errorMsg) > 0 Then 
  45.                             Response.Write "<p><font color='red'>" & errorMsg & "</font></p>" 
  46.                         End If 
  47.                     %> 
  48.                     <table width=900> 
  49.                         <tr> 
  50.                             <td>
  51.                                 <table align="center"> 
  52.                                     <tr> 
  53.                                         <td align="center"><font face="arial"><h3>Employee Grading Master</h3></font></h3> 
  54.                                     </tr> 
  55.                                 </table> 
  56.                             </td>
  57.                         </tr> 
  58.                         <tr> 
  59.                             <td>
  60.                                 <table align="center"> 
  61.                                     <tr> 
  62.                                         <td align="right"><font face="arial" size=2>Grade : </font></td> 
  63.                                         <td align='left'> 
  64.                                             <select name="vgrade"> 
  65.                                                 <option value="I" selected>I</option> 
  66.                                                 <option value="II">II</option> 
  67.                                                 <option value="III">III</option> 
  68.                                                 <option value="IV">IV</option> 
  69.                                             </select> 
  70.                                         </td> 
  71.                                     </tr> 
  72.                                     <tr> 
  73.                                         <td align="right"><font face="arial" size=2>Category : </font></td> 
  74.                                         <td align='left'> 
  75.                                             <select name="vcategory"> 
  76.                                                 <option value="Officer">Officer</option> 
  77.                                                 <option value="staff" selected>Staff</option></select> 
  78.                                             </select> 
  79.                                         </td> 
  80.                                     </tr> 
  81.                                     <tr> 
  82.                                         <td align="right"><font face="arial" size=2>Amount : </font></td> 
  83.                                         <td align='left'><input type="text" style="width:100px" name="vamount"></td> 
  84.                                     </tr> 
  85.                                 </table>  
  86.                             </td>
  87.                         </tr> 
  88.                         <tr> 
  89.                             <td>
  90.                                 <table align="center"> 
  91.                                     <tr> 
  92.                                         <td align="center">
  93.                                             <input type="Submit" name="submit" value="Save"> 
  94.                                             <input type="reset" name="reset" value="Reset"> 
  95.                                         </td> 
  96.                                     </tr> 
  97.                                 </table>
  98.                             </td>
  99.                         </tr> 
  100.                     </table> 
  101.                 </form> 
  102.             </p> 
  103.         </div> 
  104.     </body> 
  105. </html> 
  106.  

Hope this helps,
CroCrew~
Oct 12 '09 #3
jhardman
3,406 Expert 2GB
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
Oct 12 '09 #4
vikas251074
198 100+
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
Oct 13 '09 #5
vikas251074
198 100+
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.
Oct 13 '09 #6
CroCrew
564 Expert 512MB
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:

Expand|Select|Wrap|Line Numbers
  1. Set Conn = Server.CreateObject("ADODB.Connection") 
  2. Conn.Open("DSN=dsn_ois;UID=scott;PWD=tiger;") 
  3.  
  4. Set rs = Server.CreateObject("ADODB.Recordset")
  5.     SQL = "SELECT category, grade, amount FROM grademst"
  6.     rs.Open SQL, Conn
  7.  
  8.     Do Until (rs.EOF)
  9.         Response.Write("Category: " &rs("category").value & " ")
  10.         Response.Write("Grade: " &rs("grade").value & " ")
  11.         Response.Write("Amount: " &rs("amount").value)
  12.         Response.Write("<br />&nbsp;<br />")
  13.         rs.MoveNext
  14.     Loop
  15.  
Hope this helps,
CroCrew~
Oct 13 '09 #7
vikas251074
198 100+
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 ? ..
Oct 13 '09 #8
CroCrew
564 Expert 512MB
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
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <title>FormPage.asp</title>
  4.     </head>
  5.     <body>
  6.         <p>
  7.             <%
  8.                 Select Case Request("Error")
  9.                     Case "0"
  10.                         Response.Write("Update done.")
  11.                     Case "1"
  12.                         Response.Write("No update was done.")
  13.                 End Select
  14.             %>
  15.         </p>
  16.         <form name="xForm" method="post" action="PostPage.asp">
  17.             Amount: <input type="text" name="vamount">
  18.             <br />
  19.             <input type="Submit" name="submit" value="Save">
  20.         </form>
  21.     </body>
  22. </html>
  23.  
PostPage.asp
Expand|Select|Wrap|Line Numbers
  1. <%
  2.     Response.CacheControl = "no-cache"
  3.     Response.AddHeader "Pragma", "no-cache"
  4.     Response.Expires = -1
  5.  
  6.     Set Conn = Server.CreateObject("ADODB.Connection")  
  7.         Conn.Open("DSN=dsn_ois;UID=scott;PWD=tiger;")) 
  8.  
  9.         On Error Resume Next 
  10.             SQL = "INSERT INTO grademst (category, grade, amount) VALUES('Officer', 'II', '1')" 
  11.             Conn.Execute SQL 
  12.  
  13.             If Err <> 0 Then 
  14.                 Response.Redirect("FormPage.asp?Error=1")
  15.             Else
  16.                 Response.Redirect("FormPage.asp?Error=0")
  17.             End If
  18. %>
  19.  
Hope this helps,
CroCrew~
Oct 13 '09 #9

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

Similar topics

3
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...
2
by: os2 | last post by:
hi in bd.php i do: <?php $serveur = "localhost"; $utilisateur = "root"; $motDePasse = ""; $base = "laboiteaprog";
10
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?...
4
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...
16
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...
25
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);
148
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 ?
1
pbmods
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...
2
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:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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...
0
Oralloy
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,...
0
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...

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.