Link to home
Start Free TrialLog in
Avatar of fanfy
fanfy

asked on

ASP declaration

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>





ASKER CERTIFIED SOLUTION
Avatar of hongjun
hongjun
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of naveenkohli
naveenkohli

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
hongjun..
you were fraction quiker than me :-)
fanfy, if I were you, I will use sql statements.

hongjun
Avatar of fanfy

ASKER

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
 
You have strFName in your Dim statement 2 times.
Avatar of Michel Sakr
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
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.)
Disregard the last thing (about MyConn). I just saw that you did.
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
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
Avatar of fanfy

ASKER

I managed to solve the problem , thanks for your advices
How do you solve it? I am curious to know. Please manage your other questions which happen to be all opened!

hongjun
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

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
<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