Solved

ASP declaration

Posted on 2002-03-23
17
1,049 Views
Last Modified: 2007-11-27
the following problem is encountered when running addRec asp module which should invoke ASP module called
addToDatabase


here is the error of code
The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.

--------------------------------------------------------------------------------

Please try the following:

Click the Refresh button, or try again later.

Open the test home page, and then look for links to the information you want.
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

--------------------------------------------------------------------------------

Technical Information (for support personnel)

Error Type:
Microsoft VBScript runtime (0x800A01F4)
Variable is undefined: 'strRelativeID'
/200003674/project/addtodatabase.asp, line 7


Browser Type:
Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)

Page:
POST 227 bytes to /200003674/project/addtodatabase.asp

POST Data:
CustID=&FName=&LName=&Gender=&DoB=&Email=&TelWork=&TelMobil=&NetSalary=&Occpuation=--Please+select+one+--&RelativeID=&FName=&LName=&TelWork=&Occpuation=--Please+select+one+--&CCode=&CompanyName=&Telph
. . .

Time:
Saturday, March 23, 2002, 2:04:09 AM


More information:
Microsoft Support

addrecordtodatabse

the following ASp code fails.

<HTML>
<HEAD>

<TITLE>
</TITLE>

</HEAD>


<body background="file:///z:/dcs272/cheese.jpg">
<CENTER>
<H2>New Customers Registration</H2>
<form name="Search" method="Post" action="addtodatabase.asp">
<CENTER>
<TABLE CELLPADDING = "2" WIDTH = "100%" BORDER = "0" align = center >
<TR>
<TD COLSPAN=4><H2><CENTER>Personal Details</CENTER></H2></TD>
</TR>

<TR>
<TD WIDTH = "35%" >Customer ID# </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "CustID" SIZE = 20> </TD>
<TD WIDTH = "35%" >First Name </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "FName" SIZE = 20> </TD>

</TR>

<TR>

<TD WIDTH = "25%" >Last Name </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "LName" SIZE = 20> </TD>
<TD WIDTH = "25%" >Gender </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "Gender" SIZE = 20> </TD>

</TR>

<TR>

<TD WIDTH = "25%" >Date Of Birth</TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "DoB" SIZE = 20> </TD>
<TD WIDTH = "55%" >Email Address </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "Email" SIZE = 20> </TD>

</TR>
<TR>

<TD WIDTH = "25%" >Tel(work) </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "TelWork" SIZE = 20> </TD>
<TD WIDTH = "25%" >Tel(mobil) </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "TelMobil" SIZE = 20> </TD>

</TR>

<TR>

<TD WIDTH = "25%" >Net Salary </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "NetSalary" SIZE = 20> </TD>
<TD WIDTH = "25%" > Occpuation </TD>
<TD WIDTH = "100%"> <SELECT name = "Occpuation" SIZE = "1"> <OPTION select value = "--Please select
one --">

Please select one--</OPTION>
<OPTION value = "Accountant" > Accountant </OPTION>
<OPTION value = "Teacher"  > Teacher  </OPTION>
<OPTION value = "Computer Related"    > Computer Related    </OPTION>
<OPTION value = "Engineering & Tech "    > Engineering & Tech    </OPTION>
<OPTION value = "Manufacturing"   > Manufacturing  </OPTION>
<OPTION value = "Personnel"    > Personnel      </OPTION>
<OPTION value = "Others "    > Others     </OPTION>

</SELECT></TD>
</TR>

<BR></BR>
<BR></BR>
<TR>
<TD COLSPAN=4><H2><CENTER>Relative Details</CENTER></H2></TD>
</TR>
<TD WIDTH = "25%" >Relative ID# </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "RelativeID" SIZE = 20> </TD>
<TD WIDTH = "25%" >First Name </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "FName" SIZE = 20> </TD>

</TR>
<TR>

<TD WIDTH = "25%" >Last Name </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "LName" SIZE = 20> </TD>
<TD WIDTH = "25%" >Telephone(work) </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "TelWork" SIZE = 20> </TD>

</TR>
<TR>


<TD WIDTH = "25%" > Occpuation </TD>
<TD WIDTH = "100%"> <SELECT name = "Occpuation" SIZE = "1"> <OPTION select value = "--Please select
one --">

Please select one--</OPTION>
<OPTION value = "Accountant" > Accountant </OPTION>
<OPTION value = "Teacher"  > Teacher  </OPTION>
<OPTION value = "Computer Related"    > Computer Related    </OPTION>
<OPTION value = "Engineering & Tech "    > Engineering & Tech    </OPTION>
<OPTION value = "Manufacturing"   > Manufacturing  </OPTION>
<OPTION value = "Personnel"    > Personnel      </OPTION>
<OPTION value = "Others "    > Others     </OPTION>

</SELECT></TD>

</tr>
<BR></BR>
<br></BR>
<TR>
<TD COLSPAN=4><H2><CENTER>Employer Details</CENTER></H2></TD>
</TR>



<TR >
<TD WIDTH = "25%" >Company Code </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "CCode" SIZE = 20> </TD>
<TD WIDTH = "25%" >Company Name </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "CompanyName" SIZE = 20> </TD>
</TR>

<TR>

<TD WIDTH = "25%" >Telphone # </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "Telphone" SIZE = 20> </TD>
<TD WIDTH = "25%" >Fax Number </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "Fax" SIZE = 20> </TD>

</TR>
<TR>

<TD WIDTH = "25%" >No.of years with Employer </TD>
<TD WIDTH = "40%"> <INPUT TYPE = "text" NAME = "No" SIZE = 20> </TD>

</TR>


</TABLE>

<center>
<h5><i>Information rendered is declared valid</i></h5>
</center>
<BR>
</center>
<CENTER>
<input type="submit" name="btnSearch" value="Add">
<INPUT type = "reset" value = "Reset" name ="Reset">

</form>
</CENTER>

</FORM>

</CENTER>
</BODY>






HERE IS addtodatabase.asp MODULE THAT GIVES ME PROBLEM


<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include file="adovbs.inc."-->
<html>

<BODY background = "images/CHEESE.jpg">

<%
Dim MyConn,RS,RS2,RS3,strCustID,strFName, strLName, strGender, strDoB,strEmail,strTelWork, strTelMobil, strNetSalary
strOccupation,strRelativeID,strFName,strLasName,strTelWork,strOccupation,strCCode,strCompanyName,strTelphone,strFax,strNo



'grab the form contents
strCustID = Request.Form("txtCustID")
strFName = Request.Form("txtFName")
strLName = Request.Form("txtLName")
strGender = Request.Form("Gender")
strDoB = Request.Form("txtDoB")
strEmail = Request.Form("txtEmail")
strTelWork = Request.Form("txtTelWork")
strTelMobil = Request.Form("txtTelMobil")
strTelNetSalary = Request.Form("txtNetSalary")
strOccupation = Request.Form("txtOccupation")
strRelativeID = Request.Form("txtRelativeID")
strFName = Request.Form("txtFName")
strLName = Request.Form("txtLName")
strGender = Request.Form("Gender")
strDoB = Request.Form("txtDoB")
strEmail = Request.Form("txtEmail")
strTelMobil = Request.Form("txtTelMobil")
strTelWork = Request.Form("txtTelephone(work)")
strOccupation = Request.Form("txtOccupation")
strCCode=Request.Form("txtCCode")
strCompanyName=Request.Form("txtCompanyName")
strTelephone=Request.Form("txtTelephone")
strNo=Request.Form("txtNo")





Set MyConn=Server.CreateObject("ADODB.Connection")
Set RS=Server.CreateObject("ADODB.RecordSet")

'since you are working with the RecordSet you need to create an instance of
'the RecordSet Object
Set RS2=Server.CreateObject("ADODB.RecordSet")
Set RS3=Server.CreateObject("ADODB.RecordSet")
'in this case, since we're adding to two separate tables we need to create
'two instances of the RecordSet Object

MyConn.Open "PLDSloans"
'getdata is your DSN (data source name) you created through ODBC
RS.Open "Select * From Customer", MyConn, adOpenDynamic, adLockPessimistic, adCMDText
RS2.Open "Select * From Relative", MyConn, adOpenDynamic, adLockPessimistic, adCMDText
RS3.Open "Select * From Employer", MyConn, adOpenDynamic, adLockPessimistic, adCMDText
'open both RecordSets

RS.AddNew
RS("CustID")= strCustID
RS("FName")= strFName
RS("LName")= strLName
RS("Gender")= strGender
RS("DoB")= strDoB
RS("Email")= strEmail
RS("TelWork")= strTelWork
RS("TelMobil")= strTelMobil
RS("NetSalary")= strNetSalary
RS("Occupation")= strOccupation

RS.Update
'Update the first RecordSet

RS2.AddNew
RS2("RelativeID")= strRelativeID
RS2("FName")= strFName
RS2("TelWork")= strTelMobil
RS2("Occupation")= strOccupation

RS2.Update
'Update the second RecordSet

RS3.AddNew
RS3("CCode")= strCCode
RS3("CompanyName")= strCompany
RS3("Telephone")= strTelephone
RS3("Fax")= strFax
RS3("No")= strNo

RS3.Update
'Update the second RecordSet

'Clean up
RS.Close
RS2.Close
RS3.Close
MyConn.Close
Set RS = Nothing
Set RS2 = Nothing
Set RS3 = Nothing
Set MyConn = Nothing
%>

</body>
</html>





0
Comment
Question by:fanfy
  • 5
  • 2
  • 2
  • +5
17 Comments
 
LVL 33

Accepted Solution

by:
hongjun earned 100 total points
ID: 6890969
You short of 1 comma in your declaration b/w strNetSalary and strOccupation

dim ... strNetSalary, strOccupation



hongjun
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 6890972
I am not a VB person but here is one problem I see in your variable declaration. You are missing a "," after strNetSalary. It could be that since there is a break, rest of the variable names are considered undefined.

-------------------
Dim MyConn,RS,RS2,RS3,strCustID,strFName, strLName, strGender, strDoB,strEmail,strTelWork, strTelMobil,
strNetSalary   ******-->>>>>>>
strOccupation,strRelativeID,strFName,strLasName,strTelWork,strOccupation,strCCode,strCompanyName,strTelphone,strFax,strNo
---------------------

Try putting "," after strNetSalary

-------------------
Dim MyConn,RS,RS2,RS3,strCustID,strFName, strLName, strGender, strDoB,strEmail,strTelWork, strTelMobil,
strNetSalary,
strOccupation,strRelativeID,strFName,strLasName,strTelWork,strOccupation,strCCode,strCompanyName,strTelphone,strFax,strNo
---------------------

Naveen
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 6890976
hongjun..
you were fraction quiker than me :-)
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6890978
fanfy, if I were you, I will use sql statements.

hongjun
0
 

Author Comment

by:fanfy
ID: 6891010
NOW THE FOLLOWING ERROR EXIST



The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.

--------------------------------------------------------------------------------

Please try the following:

Click the Refresh button, or try again later.

Open the test home page, and then look for links to the information you want.
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

--------------------------------------------------------------------------------

Technical Information (for support personnel)

Error Type:
Microsoft VBScript compilation (0x800A0411)
Name redefined
/200003674/project/addtodatabase.asp, line 10, column 146


Browser Type:
Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)

Page:
POST 227 bytes to /200003674/project/addtodatabase.asp

POST Data:
CustID=&FName=&LName=&Gender=&DoB=&Email=&TelWork=&TelMobil=&NetSalary=&Occpuation=--Please+select+one+--&RelativeID=&FName=&LName=&TelWork=&Occpuation=--Please+select+one+--&CCode=&CompanyName=&Telph . . .

Time:
Saturday, March 23, 2002, 6:19:53 PM


More information:
Microsoft Support
 
0
 
LVL 1

Expert Comment

by:d_glenn
ID: 6891092
You have strFName in your Dim statement 2 times.
0
 
LVL 20

Expert Comment

by:Silvers5
ID: 6891137
can you stop cross posting fanfy.. you'll only waist your points this way..
keep it in one question as long as it is the same topic

cheers
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 6891148
You should look through your code and check what variabes you use, and how.

At a quick glance I also found this:

- You dimension strTelWork and strOccupation twice.
- You dimension strLasName that I don't believe that you use.
- You get eight of the values from the Request.Form twice.
- You use strFax to update a field in the database, but the value of strFax is never set.
- You ought to do MyConn.Close before you set it to nothing. (Just to be safe.)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 29

Expert Comment

by:Göran Andersson
ID: 6891352
Disregard the last thing (about MyConn). I just saw that you did.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6926628
fanfy, you have asked four questions, all of which await your comments and updates to the experts who are working to help you.

Moondancer - EE Moderator
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6938507
Please reply to all comments commented by the many experts above. They are all helpful. Perhaps you can try to change your internet settings to get to see a more detailed description.

Tools->Internet Options
Go to Advanced Tab
Make sure "Show friendly HTTP error messages" is unchecked.

Runt the page again. Post the error message here.


hongjun
0
 

Author Comment

by:fanfy
ID: 6938560
I managed to solve the problem , thanks for your advices
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6938566
How do you solve it? I am curious to know. Please manage your other questions which happen to be all opened!

hongjun
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6938743
fanfy ->  If/when you find the solution to questions you've asked here, please post them and contact us in Community Support to help you resolve the existing questions impacted by this.

Administration will be sending you an Email in these regards with the request that you update and finalize all your open questions here.  Questions you've asked that are inactive after 21 days are considered "abandoned".

Moondancer - EE Moderator

0
 
LVL 1

Expert Comment

by:madeline448
ID: 9343147
fanfy,

No comment has been added lately (more than a year now), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question.

RECOMMENDATION: PAQ/Refund. And can you please post your solution here. It maybe useful for others who had the same problem.

Please leave any comments here within seven days.

-- PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER! --

Thanks,

madeline448
EE Cleanup Volunteer
0
 
LVL 33

Expert Comment

by:hongjun
ID: 9344346
<points to hongjun>
with B grade.
I believe my first comment solved his initial problem.
Second comment helps to show the specific error message.

hongjun
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now