• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

sql insert statement for asp pages

Hello Experts,
I need your help with sql insert statement for my asp page.
Here's what I have and it's not working.
<%
Dim sql_insert, con

sql_insert = "insert into ConferenceRegistration (CRLastName, CRFirstName)values('CRLastName','CRFirstName')"
con.Execute (sql_insert)
%>
Thanks.
0
lazzydog
Asked:
lazzydog
  • 9
  • 8
  • 2
  • +1
1 Solution
 
zawedikianCommented:
hi

here s way:
      Set Sessions = Server.CreateObject("ADODB.Command")
            Sessions.ActiveConnection = [connectin string]
            Sessions.CommandText = "insert into ConferenceRegistration (CRLastName, CRFirstName) values('CRLastName','CRFirstName')"
            Sessions.execute

zeina
0
 
compukenCommented:
I would try this

sql_insert = "insert into ConferenceRegistration  (CRLastName, CRFirstName) values("'" & CRLastName & "'," &  "'" &  CRFirstName & "')"
con.Execute (sql_insert)
     

Below is a sample of one of my projects

   Dim strSQL As String = "INSERT INTO SDatabase " & _
        "(EmployeeName, EmployeeSSN, DoS, Claimant, ServType, ServAmount, Paid, AmountPaid, PayableTo) VALUES(" & _
        "'" & params(0) & "'," & _
         "'" & params(1) & "'," & _
        "'" & params(2) & "'," & _
        "'" & params(3) & "'," & _
        "'" & params(5) & "'," & _
        "'" & params(4) & "'," & _
        "'" & params(6) & "'," & _
        "'" & params(7) & "'," & _
        "'" & params(8) & "')"
       

        ExecuteStatement(strSQL)
        Conn.Close()
        Conn2.Close()
    End Sub



    Function ExecuteStatement(ByVal strSQL)
        Dim objCmd As New OleDbCommand(strSQL, Conn)

        Try
            objCmd.Connection.Open()
            objCmd.ExecuteNonQuery()
        Catch ex As Exception
            Label1.Text = "Error updating the database"
        End Try
        Label1.Text = "SUCCESS"
        objCmd.Connection.Close()
        Response.Redirect("index.aspx")
    End Function
0
 
lazzydogAuthor Commented:
I tried both suggestions, and still not working. I'm receiving this error:


Microsoft JScript compilation error '800a03ec'

Expected ';'

/ConfReg2006_New.asp, line 4

Dim sql_insert, con
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
compukenCommented:
ok you are using C#, you have to have ; at the end of your lines, code should be:

<%
Dim sql_insert, con;

sql_insert = "insert into ConferenceRegistration (CRLastName, CRFirstName)values('CRLastName','CRFirstName')";
con.Execute (sql_insert);
%>

if that doesn't work try this

<%
Dim sql_insert, con;

sql_insert = "insert into ConferenceRegistration  (CRLastName, CRFirstName) values("'" & CRLastName & "'," &  "'" &  CRFirstName & "')";
con.Execute (sql_insert);
%>

if the "sql_insert =" line goes too far and over to the line below you have to make sure that the end of the top line has this  & _
like this:
"THis line is too " & _
" long";
0
 
trainsdseCommented:
Ok, ummm NOOOOOOO!

Compuken:

1. He's not using C#, it's an asp page.  (Your first code snippet wasn't even VBScript - it was VB.Net)
2. You do NOT just add semicolons to convert vbscript to c# even if it was c#.
3. It should have been obvious the runtime environment was trying to execute JScript since that's what his error was.
4. There is no line continuation in either c# or JScript since it's built in (hence the need for semicolons).
5. Neither language (C# or JScript) use DIM for variable declaration

DUDE!!!! Just stop! Please!!!

Lazzydog,

Are you wanting to write VBScript?  That's what it looks like.  If so check to make sure your page has the correct directive at the very top of the page.  It should look like this:
<%@ Language=VBScript %>

You will need to instantiate and open your "con" object before you can use it to execute.

I'm assuming CRLastName and CRFirstName are the names of the textboxes on the page that posts to this page?

If so, the following code will fix you up, if not, let me know.  This is a very simple task that can be fixed quickly.

<%
Dim sql_insert, con, LN, FN

SET con = Server.CreateObject("adodb.connection")
'The following connection string assumes SQL server and that it exists on your machine
'It will need to be changed to point to the database you are trying to connect to.
con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=(local);INITIAL CATALOG=YourDatabaseName;USER ID=sa;PASSWORD="

LN = Replace(Request("CRLastName"),"'","''")
FN = Replace(Request("CRFirstName"),"'","''")

sql_insert = "insert into ConferenceRegistration (CRLastName, CRFirstName) values( '" & LN & "','" & FN & "' )"
con.Execute (sql_insert)

con.close
SET con = Nothing
%>
0
 
lazzydogAuthor Commented:
ummm actually I'm using JAVAScript
At top of my page looks like this:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
0
 
lazzydogAuthor Commented:
trainsdse,

Does the code above works with JAVASCRIPT?
0
 
trainsdseCommented:
Nope, but gimme 5 minutes and I'll resend in javascript.
0
 
trainsdseCommented:
<%
var sql_insert, con;
var LN=new String(Request("CRLastName"));
var FN=new String(Request("CRFirstName"));

con = new ActiveXObject("adodb.connection");
try{
//'The following connection string assumes SQL server and that it exists on your machine
//'It will need to be changed to point to the database you are trying to connect to.
con.Open("PROVIDER=SQLOLEDB;DATA SOURCE=(local);INITIAL CATALOG=lemdev;USER ID=sa;PASSWORD=");

var repChars="''";
LN = LN.replace(/\'/g,repChars);
FN = FN.replace(/\'/g,repChars);

}catch(e){
      Response.Write(e.message);
      Response.End();
}

sql_insert = "insert into ConferenceRegistration (CRLastName, CRFirstName) values( '" + LN + "','" + FN + "' )";
con.Execute (sql_insert);

con.Close();
con=null;
%>

Tested on my machine and works well.
0
 
lazzydogAuthor Commented:
Thanks, I'll try it tomorrow.
For this part  would I write it like this,  since I didn't set a password for my database?

con.Open("PROVIDER=SQLOLEDB;DATA SOURCE="C:\Inetpub\wwroot\mnawwa\Database\ConfReg06.mdb";INITIAL CATALOG=lemdev");

0
 
trainsdseCommented:
It would be:

con.Open("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=C:\\Inetpub\\wwroot\\mnawwa\\Database\\ConfReg06.mdb");
0
 
lazzydogAuthor Commented:
Looks like it's almost working, in my access table instead of inserting the data I entered on my form it's inserted "underfined" for both CRLastName and CRFirstName columns.  Do you have any ideas why?Thanks.
0
 
trainsdseCommented:
can you post the html of the page?
0
 
lazzydogAuthor Commented:
Sure, the code of my asp form page: Thanks.

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connConfReg06.asp" -->
<%
var sql_insert, con;
var LN=new String(Request("CRLastName"));
var FN=new String(Request("CRFirstName"));

con = new ActiveXObject("adodb.connection");
try{
//'The following connection string assumes SQL server and that it exists on your machine
//'It will need to be changed to point to the database you are trying to connect to.
con.Open("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=C:\\Inetpub\\wwwroot\\mnawwa\\Database\\ConfReg06.mdb");

var repChars="''";
LN = LN.replace(/\'/g,repChars);
FN = FN.replace(/\'/g,repChars);

}catch(e){
     Response.Write(e.message);
     Response.End();
}

sql_insert = "insert into ConferenceRegistration (CRLastName, CRFirstName) values( '" + LN + "','" + FN + "' )";
con.Execute (sql_insert);

con.Close();
con=null;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<style type="text/css">
<!--
.style1 {
      font-family: "Times New Roman", Times, serif;
      font-size: 14px;
}
.style7 {font-family: "Times New Roman", Times, serif; font-size: 14px; font-weight: bold; }
.style10 {
      font-size: 14px;
      font-weight: bold;
}
.style11 {font-family: "Times New Roman", Times, serif}
.style13 {
      color: #000000;
      font-family: "Times New Roman", Times, serif;
      font-size: 24px;
}
.style14 {color: #000000}
.style16 {
      color: #000000;
      font-style: italic;
      font-size: 18px;
}
.style17 {
      font-size: 14px;
      font-style: italic;
}
.style19 {font-family: "Times New Roman", Times, serif; font-size: 14px; font-style: italic; }
.style20 {color: #FF0000}
-->
</style>
</head>
</html>
&nbsp;
<html>
<head>
<title>MN Awwa Conference Online Registration</title>
<script language="javascript">
      <!--
      
      function Disabler(){
            if(document.frmRegistration.RegType[0].checked == true){
            
                  document.frmRegistration.CROneDayWed.disabled = true;
                  document.frmRegistration.CROneDayThur.disabled = true;
                  document.frmRegistration.CROneDayFri.disabled = true;                  
                  document.frmRegistration.CRRegular.disabled = false;
                  document.frmRegistration.CRRetiree.disabled = false;                  
                  document.frmRegistration.CRStuWed.disabled = true;
                  document.frmRegistration.CRStuThur.disabled = true;
                   document.frmRegistration.CRStuFri.disabled = true;
      }
            if(document.frmRegistration.RegType[1].checked == true){
                  document.frmRegistration.CROneDayWed.disabled = false;
                  document.frmRegistration.CROneDayThur.disabled = false;
                  document.frmRegistration.CROneDayFri.disabled = false;
                  document.frmRegistration.CRRegular.disabled = true;
                  document.frmRegistration.CRRetiree.disabled = true;
                  document.frmRegistration.CRStuWed.disabled = true;
                  document.frmRegistration.CRStuThur.disabled = true;
                  document.frmRegistration.CRStuFri.disabled = true;
            }
                  if(document.frmRegistration.RegType[2].checked == true){
                  document.frmRegistration.CROneDayWed.disabled = true;
                  document.frmRegistration.CROneDayThur.disabled = true;
                  document.frmRegistration.CROneDayFri.disabled = true;
                  document.frmRegistration.CRRegular.disabled = true;
                  document.frmRegistration.CRRetiree.disabled = true;
                  document.frmRegistration.CRStuWed.disabled = false;
                  document.frmRegistration.CRStuThur.disabled = false;
                  document.frmRegistration.CRStuFri.disabled = false;                  
            }
      }
      
function asMoney(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num)) num = "0";
cents = Math.floor((num*100+0.5)%100);
num = Math.floor(num).toString();
if(cents < 10) cents = "0" + cents;
return (num + '.' + cents);
}
function calcRegularRegistration() {
      var Regular = asMoney(0.00)
      if (document.frmRegistration.CRRegular.checked){
            var prereg =180.00
            Regular = asMoney(prereg)
            }
      else {
            Regular = " "
            }
      return Regular
}


function calcRetireeRegistration() {
      var Retiree = asMoney(0.00)
      if (document.frmRegistration.CRRetiree.checked){
            var prereg =55.00
            Retiree = asMoney(prereg)
            }
      else {
            Retiree = " "
            }
      return Retiree
}
function calcOneDayWed() {
      var OneWed = asMoney(0.00)
      if (document.frmRegistration.CROneDayWed.checked){
            var prereg =80.00
            OneWed = asMoney(prereg)
            }
      else {
            OneWed = " "
            }
      return OneWed
}
function calcOneDayThur() {
      var OneThur = asMoney(0.00)
      if (document.frmRegistration.CROneDayThur.checked){
            var prereg =80.00
            OneThur = asMoney(prereg)
            }
      else {
            OneThur = " "
            }
      return OneThur
}
function calcOneDayFri() {
      var OneFri = asMoney(0.00)
      if (document.frmRegistration.CROneDayFri.checked){
            var prereg =80.00
            OneFri = asMoney(prereg)
            }
      else {
            OneFri = " "
            }
      return OneFri
}
function calcStudentWed() {
      var StuWed = asMoney(0.00)
      if (document.frmRegistration.CRStuWed.checked){
            var prereg =10.00
            StuWed = asMoney(prereg)
            }
      else {
            StuWed = " "
            }
      return StuWed
}
function calcStudentThur() {
      var StuThur = asMoney(0.00)
      if (document.frmRegistration.CRStuThur.checked){
            var prereg =10.00
            StuThur = asMoney(prereg)
            }
      else {
            StuThur = " "
            }
      return StuThur
}
function calcStudentFri() {
      var StuFri = asMoney(0.00)
      if (document.frmRegistration.CRStuFri.checked){
            var prereg =10.00
            StuFri = asMoney(prereg)
            }
      else {
            StuFri = " "
            }
      return StuFri
}
function calcGuest() {
      var Guest = asMoney(0.00)
      if (document.frmRegistration.CRGuest.checked){
            var prereg =55.00
            Guest = asMoney(prereg)
            }
      else {
            Guest = " "
            }
      return Guest
}
function calcticket() {
if (document.frmRegistration.CRTicket.value==1) {
tick = document.frmRegistration.CRTicket.value*30
}
else{
tick = document.frmRegistration.CRTicket.value*30
}
return tick
}
function showname() {
if (document.frmRegistration.CRFirstName.value) {
tick = document.frmRegistration.CRFirstName.value
}
else{
tick = document.frmRegistration.CRFirstName.value
}
return tick
}      
function calcFinalTot() {

      var gtot=document.frmRegistration.x_regular.value*1+document.frmRegistration.x_retiree.value*1+document.frmRegistration.x_onewed.value*1+document.frmRegistration.x_onethur.value*1+document.frmRegistration.x_onefri.value*1+document.frmRegistration.x_stuwed.value*1+document.frmRegistration.x_stuthur.value*1+document.frmRegistration.x_stufri.value*1+document.frmRegistration.x_guest.value*1+document.frmRegistration.x_ticket.value*1

var grandtot=asMoney(gtot)

      return grandtot

}
function CheckRegisration() {
document.frmRegistration.x_regular.value = calcRegularRegistration()
document.frmRegistration.x_retiree.value = calcRetireeRegistration()
document.frmRegistration.x_onewed.value = calcOneDayWed()
document.frmRegistration.x_onethur.value = calcOneDayThur()
document.frmRegistration.x_onefri.value = calcOneDayFri()
document.frmRegistration.x_stuwed.value = calcStudentWed()
document.frmRegistration.x_stuthur.value = calcStudentThur()
document.frmRegistration.x_stufri.value = calcStudentFri()
document.frmRegistration.x_guest.value = calcGuest()
document.frmRegistration.x_ticket.value = calcticket()
document.frmRegistration.x_show.value = showname()

document.frmRegistration.x_Amount.value = calcFinalTot()
return 0
}       

      //-->
      </script>
</head>
<body TOPMARGIN="1" LEFTMARGIN="1" RIGHTMARGIN="0" BOTTOMMARGIN="0">

<LINK rel="stylesheet" type="text/css" href="/includes/NationalStyle.css">
<LINK REL="SHORTCUT ICON" HREF="/favicon.ico">
<span id="noprint_header">
<!-- BEGIN: HEADER -->
<!-- END: HEADER -->
</span>
<form action="ConfReg2006Confirm.asp" method="post" name="frmRegistration">
  <p align="center" class="style20" style="margin-top: 0; margin-bottom: 0">PAGE UNDER CONSTRUCTION!!! </p>
  <p align="center" class="style13">&nbsp;</p>
  <p align="center">&nbsp;</p>
  <table cellpadding="10" cellspacing="0" width="103%" style="border-collapse: collapse" bordercolor="#111111">
    <tr>
      <td class="Groovy"><p> <font face="Times New Roman">First Name:
            <input name="CRFirstName" type="text" id="CRFirstName" size="20" />
          </font><font face="Times New Roman">&nbsp; Last Name:
          <input name="CRLastName" type="text" id="CRLastName" size="20">
          Title:
          <input name="CRTitle" type="text" id="CRTitle" size="30">
          </font></p>
        <p><font face="Times New Roman">Employer:
          <input name="CREmployer" type="text" id="CREmployer" size="45">
          </font></p>
        <p><font face="Times New Roman">Street Address:
          <input name="CRAddress" type="text" id="CRAddress" size="35">
          </font><font face="Times New Roman"> City:
          <input name="CRCity" type="text" id="CRCity" size="20" />
          State:
          <input name="CRState" type="text" id="CRState" size="10">
          Zip:
          <input name="CRZip" type="text" id="CRZip" size="9">
          </font></p>
        <p><font face="Times New Roman">Phone:
          <input name="CRPhone" type="text" id="CRPhone" size="11">
          </font><font face="Times New Roman"> Fax:
          <input name="CRFax" type="text" id="CRFax" size="11">
          Email:
          <input name="CREmail" type="text" id="CREmail" size="30">
          </font></p>
        <p><font face="Times New Roman">Please send me information about the Vendor
          Exhibition
          <input name="CRVendor" type="checkbox" id="CRVendor" value="ON">
          </font></p>
        <table width="744" border="0">
          <tr>
            <td width="194"><span style="margin-top: 0"> <font face="Times New Roman">Are you an AWWA member?</font></span></td>
            <td width="36"><font face="Times New Roman">Yes</font></td>
            <td width="500"><font face="Times New Roman">
              <input type="radio" value="Member" checked="checked" name="radmember" />
              Member Number:
              <input name="CRMemberNum" type="text" id="CRMemberNum" size="9" />
              </font></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><font face="Times New Roman">No</font></td>
            <td><font face="Times New Roman">
              <input type="radio" name="radmember" value="Not Member" />
              </font></td>
          </tr>
        </table>
        <p align="center"><b><font face="Times New Roman" size="5">Registration
          Information</font></b></p>
        <table cellpadding="0" cellspacing="0" width="82%">
          <tr>
            <td colspan="2"><pre class="style1"><input type="radio" name="RegType" value="FULL" onclick="javascript:Disabler();" checked><b>Full Registration
</b><i>Includes all conference technical sessions, Wednesday, Thursday, and Friday luncheons, Wednesday evening social, and Thursday <br />evening banquet</i><label></label></pre>            </td>
          </tr>
          <tr>
            <td><span class="style1">
              <label>
              <input name="CRRegular" type="checkbox" id="CRRegular" value="Regular" />
              </label>
              Regular </span></td>
            <td>$180 <span class="style1">($230 after 9/13/2006) </span></td>
          </tr>
          <tr>
            <td width="22%"><span class="style1"><i><i>
              <label>
              <input name="CRRetiree" type="checkbox" id="CRRetiree" value="Retiree" />
              </label>
              </i></i>Retiree </span></td>
            <td width="78%">$55</td>
          </tr>
          <tr>
            <td colspan="2"><div style="">
                <pre><font face="Times New Roman">
<input type="radio" name="RegType" value="ONE_DAY" onclick="javascript:Disabler();" /><span class="style7">One-Day Registration</span></font>
<span class="style19"><font face="Times New Roman">Includes all conference technical sessions for that day and one </font></span><span class="style17"><font face="Times New Roman">luncheon</font></span><span class="style19"><font face="Times New Roman"> ticket                  </font></span></pre>
              </div></td>
          </tr>
          <tr>
            <td colspan="2"><table cellpadding="0" cellspacing="0" width="100%">
                <tr>
                  <td><font face="Times New Roman">
                    <input name="CROneDayWed" type="checkbox" id="CROneDayWed" value="One_Day Wednesday" />
                    Wednesday </font></td>
                  <td>$80 <span class="style1">($110 after 9/13/2006) </span></td>
                </tr>
                <tr>
                  <td><font face="Times New Roman">
                    <input name="CROneDayThur" type="checkbox" id="CROneDayThur" value="One-Day Thursday" />
                    Thursday </font></td>
                  <td>$80 <span class="style1">($110 after 9/13/2006) </span></td>
                </tr>
                <tr>
                  <td><font face="Times New Roman">
                    <input name="CROneDayFri" type="checkbox" id="CROneDayFri" value="One-Day Friday" />
                    Friday </font></td>
                  <td>$80 <span class="style1">($110 after 9/13/2006) </span></td>
                </tr>
                <tr>
                  <td colspan="2"><pre><font face="Times New Roman"><span class="style1">
<input type="radio" name="RegType" value="ONE_DAY" onclick="javascript:Disabler();" /><b>Student Registration</b></span></font>
<span class="style1"><em>Must be enrolled in an educational institution at least half time. Includes technical sessions and lunch for registered date(s). </em></span></pre>                  </td>
                </tr>
                <tr>
                  <td width="22%"><font face="Times New Roman">
                    <input name="CRStuWed" type="checkbox" id="CRStuWed" value="Student - Wednesday" />
                    Wednesday </font></td>
                  <td width="78%">$10</td>
                </tr>
                <tr>
                  <td><font face="Times New Roman">
                    <input name="CRStuThur" type="checkbox" id="CRStuThur" value="Student Thursday" />
                    Thursday </font></td>
                  <td>$10</td>
                </tr>
                <tr>
                  <td><font face="Times New Roman">
                    <input name="CRStuFri" type="checkbox" id="CRStuFri" value="Student Friday" />
                    Friday </font></td>
                  <td>$10</td>
                </tr>
              </table>
              <pre style="margin-bottom: 0"><span class="style1"><input name="CRGuest" type="checkbox" id="CRGuest" value="Guest Registraion:"><b>Guest/Spouse Program</b><i>
Includes conference activities,  entrance to Vendor Exhibition, continental breakfasts, Wednesday Evening social, <br />and Thursday banquet</i></span></pre>            </td>
          </tr>
          <tr>
            <td><span class="style1"> Name:
              <input name="GuestName" type="text" id="GuestName" value="" size="25" maxlength="40" />
              </span></td>
            <td class="style11">$55</td>
          </tr>
          <tr>
            <td colspan="2"><pre class="style10"><font face="Times New Roman">
Additional Ticket(s) for Thursday Banquet</font></pre>            </td>
          </tr>
          <tr>
            <td>Quantity: <b><font face="Times New Roman">
              <select name="CRTicket" id="CRTicket">
                <option value="0" selected>0</option>
                <option value="1">1</option>
                <option value="2">2</option>
              </select>
              </font></b></td>
            <td class="style11">$30</td>
          </tr>
          <tr>
            <td colspan="2"><pre class="style10"><label></label>
            </pre></td>
          </tr>
        </table></td>
    </tr>
  </table>
  <p align="center"> <i> <font face="Bookman Old Style" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="reset" value="Reset" name="B2" />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input name="Submit" type="submit" onclick="CheckRegisration()" value="Submit" />
    </a></font></i><br />
  </p>
  <p>
    <input name="x_regular" type="hidden" id="x_regular" />
    <input name="x_retiree" type="hidden" id="x_retiree" />
    <input name="x_onewed" type="hidden" id="x_onewed" />
    <input name="x_onethur" type="hidden" id="x_onethur" />
    <input name="x_onefri" type="hidden" id="x_onefri" />
    <input name="x_stuwed" type="hidden" id="x_stuwed" />
    <input name="x_stuthur" type="hidden" id="x_stuthur" />
    <input name="x_stufri" type="hidden" id="x_stufri" />
    <input name="x_guest" type="hidden" id="x_guest" />
    <input name="x_ticket" type="hidden" id="x_ticket" />
    <input name="x_Amount" type="hidden" id="x_Amount" />
    <input name="x_show" type="hidden" id="x_show" />
  </p>
</form>
<script language="javascript">
                              <!--
                                    Disabler();
                              //-->
                                          </script>
</td>
</tr>
<!-- End code -->
<!-- located here for compatibility, fresh code/fixing code please direct to: -->
<span id="noprint_footer">
<!-- BEGIN: FOOTER -->
<!-- END: FOOTER -->
</span>
</td>

</body>
</html>

0
 
trainsdseCommented:
Try this page, I added a check for whether or not this page is posting back or if you just came here for the first time.  Besides the if statement at the top, there is a new hidden input right after the form starts to support this.  Watch out for the word wrap on the data source param in the connection string when you copy this text.


<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<%
if(Request("postback")=="1"){
      var sql_insert, con;
      var LN=new String(Request("CRLastName"));
      var FN=new String(Request("CRFirstName"));

      con = new ActiveXObject("adodb.connection");
      try{
      //'The following connection string assumes SQL server and that it exists on your machine
      //'It will need to be changed to point to the database you are trying to connect to.
      con.Open("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=C:\\Inetpub\\wwwroot\\mnawwa\\Database\\ConfReg06.mdb");
      var repChars="''";
      LN = LN.replace(/\'/g,repChars);
      FN = FN.replace(/\'/g,repChars);

      }catch(e){
           Response.Write(e.message);
           Response.End();
      }

      sql_insert = "insert into ConferenceRegistration (CRLastName, CRFirstName) values( '" + LN + "','" + FN + "' )";
      con.Execute (sql_insert);

      con.Close();
      con=null;
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<style type="text/css">
<!--
.style1 {
     font-family: "Times New Roman", Times, serif;
     font-size: 14px;
}
.style7 {font-family: "Times New Roman", Times, serif; font-size: 14px; font-weight: bold; }
.style10 {
     font-size: 14px;
     font-weight: bold;
}
.style11 {font-family: "Times New Roman", Times, serif}
.style13 {
     color: #000000;
     font-family: "Times New Roman", Times, serif;
     font-size: 24px;
}
.style14 {color: #000000}
.style16 {
     color: #000000;
     font-style: italic;
     font-size: 18px;
}
.style17 {
     font-size: 14px;
     font-style: italic;
}
.style19 {font-family: "Times New Roman", Times, serif; font-size: 14px; font-style: italic; }
.style20 {color: #FF0000}
-->
</style>
</head>
</html>
&nbsp;
<html>
<head>
<title>MN Awwa Conference Online Registration</title>
<script language="javascript">
     <!--
     
     function Disabler(){
          if(document.frmRegistration.RegType[0].checked == true){
         
               document.frmRegistration.CROneDayWed.disabled = true;
               document.frmRegistration.CROneDayThur.disabled = true;
               document.frmRegistration.CROneDayFri.disabled = true;              
               document.frmRegistration.CRRegular.disabled = false;
               document.frmRegistration.CRRetiree.disabled = false;              
               document.frmRegistration.CRStuWed.disabled = true;
               document.frmRegistration.CRStuThur.disabled = true;
                document.frmRegistration.CRStuFri.disabled = true;
     }
          if(document.frmRegistration.RegType[1].checked == true){
               document.frmRegistration.CROneDayWed.disabled = false;
               document.frmRegistration.CROneDayThur.disabled = false;
               document.frmRegistration.CROneDayFri.disabled = false;
               document.frmRegistration.CRRegular.disabled = true;
               document.frmRegistration.CRRetiree.disabled = true;
               document.frmRegistration.CRStuWed.disabled = true;
               document.frmRegistration.CRStuThur.disabled = true;
               document.frmRegistration.CRStuFri.disabled = true;
          }
               if(document.frmRegistration.RegType[2].checked == true){
               document.frmRegistration.CROneDayWed.disabled = true;
               document.frmRegistration.CROneDayThur.disabled = true;
               document.frmRegistration.CROneDayFri.disabled = true;
               document.frmRegistration.CRRegular.disabled = true;
               document.frmRegistration.CRRetiree.disabled = true;
               document.frmRegistration.CRStuWed.disabled = false;
               document.frmRegistration.CRStuThur.disabled = false;
               document.frmRegistration.CRStuFri.disabled = false;              
          }
     }
     
function asMoney(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num)) num = "0";
cents = Math.floor((num*100+0.5)%100);
num = Math.floor(num).toString();
if(cents < 10) cents = "0" + cents;
return (num + '.' + cents);
}
function calcRegularRegistration() {
     var Regular = asMoney(0.00)
     if (document.frmRegistration.CRRegular.checked){
          var prereg =180.00
          Regular = asMoney(prereg)
          }
     else {
          Regular = " "
          }
     return Regular
}


function calcRetireeRegistration() {
     var Retiree = asMoney(0.00)
     if (document.frmRegistration.CRRetiree.checked){
          var prereg =55.00
          Retiree = asMoney(prereg)
          }
     else {
          Retiree = " "
          }
     return Retiree
}
function calcOneDayWed() {
     var OneWed = asMoney(0.00)
     if (document.frmRegistration.CROneDayWed.checked){
          var prereg =80.00
          OneWed = asMoney(prereg)
          }
     else {
          OneWed = " "
          }
     return OneWed
}
function calcOneDayThur() {
     var OneThur = asMoney(0.00)
     if (document.frmRegistration.CROneDayThur.checked){
          var prereg =80.00
          OneThur = asMoney(prereg)
          }
     else {
          OneThur = " "
          }
     return OneThur
}
function calcOneDayFri() {
     var OneFri = asMoney(0.00)
     if (document.frmRegistration.CROneDayFri.checked){
          var prereg =80.00
          OneFri = asMoney(prereg)
          }
     else {
          OneFri = " "
          }
     return OneFri
}
function calcStudentWed() {
     var StuWed = asMoney(0.00)
     if (document.frmRegistration.CRStuWed.checked){
          var prereg =10.00
          StuWed = asMoney(prereg)
          }
     else {
          StuWed = " "
          }
     return StuWed
}
function calcStudentThur() {
     var StuThur = asMoney(0.00)
     if (document.frmRegistration.CRStuThur.checked){
          var prereg =10.00
          StuThur = asMoney(prereg)
          }
     else {
          StuThur = " "
          }
     return StuThur
}
function calcStudentFri() {
     var StuFri = asMoney(0.00)
     if (document.frmRegistration.CRStuFri.checked){
          var prereg =10.00
          StuFri = asMoney(prereg)
          }
     else {
          StuFri = " "
          }
     return StuFri
}
function calcGuest() {
     var Guest = asMoney(0.00)
     if (document.frmRegistration.CRGuest.checked){
          var prereg =55.00
          Guest = asMoney(prereg)
          }
     else {
          Guest = " "
          }
     return Guest
}
function calcticket() {
if (document.frmRegistration.CRTicket.value==1) {
tick = document.frmRegistration.CRTicket.value*30
}
else{
tick = document.frmRegistration.CRTicket.value*30
}
return tick
}
function showname() {
if (document.frmRegistration.CRFirstName.value) {
tick = document.frmRegistration.CRFirstName.value
}
else{
tick = document.frmRegistration.CRFirstName.value
}
return tick
}    
function calcFinalTot() {

     var gtot=document.frmRegistration.x_regular.value*1+document.frmRegistration.x_retiree.value*1+document.frmRegistration.x_onewed.value*1+document.frmRegistration.x_onethur.value*1+document.frmRegistration.x_onefri.value*1+document.frmRegistration.x_stuwed.value*1+document.frmRegistration.x_stuthur.value*1+document.frmRegistration.x_stufri.value*1+document.frmRegistration.x_guest.value*1+document.frmRegistration.x_ticket.value*1

var grandtot=asMoney(gtot)

     return grandtot

}
function CheckRegisration() {
document.frmRegistration.x_regular.value = calcRegularRegistration()
document.frmRegistration.x_retiree.value = calcRetireeRegistration()
document.frmRegistration.x_onewed.value = calcOneDayWed()
document.frmRegistration.x_onethur.value = calcOneDayThur()
document.frmRegistration.x_onefri.value = calcOneDayFri()
document.frmRegistration.x_stuwed.value = calcStudentWed()
document.frmRegistration.x_stuthur.value = calcStudentThur()
document.frmRegistration.x_stufri.value = calcStudentFri()
document.frmRegistration.x_guest.value = calcGuest()
document.frmRegistration.x_ticket.value = calcticket()
document.frmRegistration.x_show.value = showname()

document.frmRegistration.x_Amount.value = calcFinalTot()
return 0
}      

     //-->
     </script>
</head>
<body TOPMARGIN="1" LEFTMARGIN="1" RIGHTMARGIN="0" BOTTOMMARGIN="0">

<LINK rel="stylesheet" type="text/css" href="/includes/NationalStyle.css">
<LINK REL="SHORTCUT ICON" HREF="/favicon.ico">
<span id="noprint_header">
<!-- BEGIN: HEADER -->
<!-- END: HEADER -->
</span>
<form action="ConfReg2006Confirm.asp" method="post" name="frmRegistration">
      <input type=hidden name=postback value=1>
  <p align="center" class="style20" style="margin-top: 0; margin-bottom: 0">PAGE UNDER CONSTRUCTION!!! </p>
  <p align="center" class="style13">&nbsp;</p>
  <p align="center">&nbsp;</p>
  <table cellpadding="10" cellspacing="0" width="103%" style="border-collapse: collapse" bordercolor="#111111">
    <tr>
      <td class="Groovy"><p> <font face="Times New Roman">First Name:
            <input name="CRFirstName" type="text" id="CRFirstName" size="20" />
          </font><font face="Times New Roman">&nbsp; Last Name:
          <input name="CRLastName" type="text" id="CRLastName" size="20">
          Title:
          <input name="CRTitle" type="text" id="CRTitle" size="30">
          </font></p>
        <p><font face="Times New Roman">Employer:
          <input name="CREmployer" type="text" id="CREmployer" size="45">
          </font></p>
        <p><font face="Times New Roman">Street Address:
          <input name="CRAddress" type="text" id="CRAddress" size="35">
          </font><font face="Times New Roman"> City:
          <input name="CRCity" type="text" id="CRCity" size="20" />
          State:
          <input name="CRState" type="text" id="CRState" size="10">
          Zip:
          <input name="CRZip" type="text" id="CRZip" size="9">
          </font></p>
        <p><font face="Times New Roman">Phone:
          <input name="CRPhone" type="text" id="CRPhone" size="11">
          </font><font face="Times New Roman"> Fax:
          <input name="CRFax" type="text" id="CRFax" size="11">
          Email:
          <input name="CREmail" type="text" id="CREmail" size="30">
          </font></p>
        <p><font face="Times New Roman">Please send me information about the Vendor
          Exhibition
          <input name="CRVendor" type="checkbox" id="CRVendor" value="ON">
          </font></p>
        <table width="744" border="0">
          <tr>
            <td width="194"><span style="margin-top: 0"> <font face="Times New Roman">Are you an AWWA member?</font></span></td>
            <td width="36"><font face="Times New Roman">Yes</font></td>
            <td width="500"><font face="Times New Roman">
              <input type="radio" value="Member" checked="checked" name="radmember" />
              Member Number:
              <input name="CRMemberNum" type="text" id="CRMemberNum" size="9" />
              </font></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><font face="Times New Roman">No</font></td>
            <td><font face="Times New Roman">
              <input type="radio" name="radmember" value="Not Member" />
              </font></td>
          </tr>
        </table>
        <p align="center"><b><font face="Times New Roman" size="5">Registration
          Information</font></b></p>
        <table cellpadding="0" cellspacing="0" width="82%">
          <tr>
            <td colspan="2"><pre class="style1"><input type="radio" name="RegType" value="FULL" onclick="javascript:Disabler();" checked><b>Full Registration
</b><i>Includes all conference technical sessions, Wednesday, Thursday, and Friday luncheons, Wednesday evening social, and Thursday <br />evening banquet</i><label></label></pre>            </td>
          </tr>
          <tr>
            <td><span class="style1">
              <label>
              <input name="CRRegular" type="checkbox" id="CRRegular" value="Regular" />
              </label>
              Regular </span></td>
            <td>$180 <span class="style1">($230 after 9/13/2006) </span></td>
          </tr>
          <tr>
            <td width="22%"><span class="style1"><i><i>
              <label>
              <input name="CRRetiree" type="checkbox" id="CRRetiree" value="Retiree" />
              </label>
              </i></i>Retiree </span></td>
            <td width="78%">$55</td>
          </tr>
          <tr>
            <td colspan="2"><div style="">
                <pre><font face="Times New Roman">
<input type="radio" name="RegType" value="ONE_DAY" onclick="javascript:Disabler();" /><span class="style7">One-Day Registration</span></font>
<span class="style19"><font face="Times New Roman">Includes all conference technical sessions for that day and one </font></span><span class="style17"><font face="Times New Roman">luncheon</font></span><span class="style19"><font face="Times New Roman"> ticket                  </font></span></pre>
              </div></td>
          </tr>
          <tr>
            <td colspan="2"><table cellpadding="0" cellspacing="0" width="100%">
                <tr>
                  <td><font face="Times New Roman">
                    <input name="CROneDayWed" type="checkbox" id="CROneDayWed" value="One_Day Wednesday" />
                    Wednesday </font></td>
                  <td>$80 <span class="style1">($110 after 9/13/2006) </span></td>
                </tr>
                <tr>
                  <td><font face="Times New Roman">
                    <input name="CROneDayThur" type="checkbox" id="CROneDayThur" value="One-Day Thursday" />
                    Thursday </font></td>
                  <td>$80 <span class="style1">($110 after 9/13/2006) </span></td>
                </tr>
                <tr>
                  <td><font face="Times New Roman">
                    <input name="CROneDayFri" type="checkbox" id="CROneDayFri" value="One-Day Friday" />
                    Friday </font></td>
                  <td>$80 <span class="style1">($110 after 9/13/2006) </span></td>
                </tr>
                <tr>
                  <td colspan="2"><pre><font face="Times New Roman"><span class="style1">
<input type="radio" name="RegType" value="ONE_DAY" onclick="javascript:Disabler();" /><b>Student Registration</b></span></font>
<span class="style1"><em>Must be enrolled in an educational institution at least half time. Includes technical sessions and lunch for registered date(s). </em></span></pre>                  </td>
                </tr>
                <tr>
                  <td width="22%"><font face="Times New Roman">
                    <input name="CRStuWed" type="checkbox" id="CRStuWed" value="Student - Wednesday" />
                    Wednesday </font></td>
                  <td width="78%">$10</td>
                </tr>
                <tr>
                  <td><font face="Times New Roman">
                    <input name="CRStuThur" type="checkbox" id="CRStuThur" value="Student Thursday" />
                    Thursday </font></td>
                  <td>$10</td>
                </tr>
                <tr>
                  <td><font face="Times New Roman">
                    <input name="CRStuFri" type="checkbox" id="CRStuFri" value="Student Friday" />
                    Friday </font></td>
                  <td>$10</td>
                </tr>
              </table>
              <pre style="margin-bottom: 0"><span class="style1"><input name="CRGuest" type="checkbox" id="CRGuest" value="Guest Registraion:"><b>Guest/Spouse Program</b><i>
Includes conference activities,  entrance to Vendor Exhibition, continental breakfasts, Wednesday Evening social, <br />and Thursday banquet</i></span></pre>            </td>
          </tr>
          <tr>
            <td><span class="style1"> Name:
              <input name="GuestName" type="text" id="GuestName" value="" size="25" maxlength="40" />
              </span></td>
            <td class="style11">$55</td>
          </tr>
          <tr>
            <td colspan="2"><pre class="style10"><font face="Times New Roman">
Additional Ticket(s) for Thursday Banquet</font></pre>            </td>
          </tr>
          <tr>
            <td>Quantity: <b><font face="Times New Roman">
              <select name="CRTicket" id="CRTicket">
                <option value="0" selected>0</option>
                <option value="1">1</option>
                <option value="2">2</option>
              </select>
              </font></b></td>
            <td class="style11">$30</td>
          </tr>
          <tr>
            <td colspan="2"><pre class="style10"><label></label>
            </pre></td>
          </tr>
        </table></td>
    </tr>
  </table>
  <p align="center"> <i> <font face="Bookman Old Style" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="reset" value="Reset" name="B2" />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input name="Submit" type="submit" onclick="CheckRegisration()" value="Submit" />
    </a></font></i><br />
  </p>
  <p>
    <input name="x_regular" type="hidden" id="x_regular" />
    <input name="x_retiree" type="hidden" id="x_retiree" />
    <input name="x_onewed" type="hidden" id="x_onewed" />
    <input name="x_onethur" type="hidden" id="x_onethur" />
    <input name="x_onefri" type="hidden" id="x_onefri" />
    <input name="x_stuwed" type="hidden" id="x_stuwed" />
    <input name="x_stuthur" type="hidden" id="x_stuthur" />
    <input name="x_stufri" type="hidden" id="x_stufri" />
    <input name="x_guest" type="hidden" id="x_guest" />
    <input name="x_ticket" type="hidden" id="x_ticket" />
    <input name="x_Amount" type="hidden" id="x_Amount" />
    <input name="x_show" type="hidden" id="x_show" />
  </p>
</form>
<script language="javascript">
                         <!--
                              Disabler();
                         //-->
                                     </script>
</td>
</tr>
<!-- End code -->
<!-- located here for compatibility, fresh code/fixing code please direct to: -->
<span id="noprint_footer">
<!-- BEGIN: FOOTER -->
<!-- END: FOOTER -->
</span>
</td>

</body>
</html>

0
 
lazzydogAuthor Commented:
Nope that didn't do it, and also it didn't insert a record into database at all.
0
 
trainsdseCommented:
You are loading the page, typing into the fields, and pressing the submit button right?  I only ask because I created a test mdb and table and it worked on mine.  Also the reason it put undefined into your db before was because it ran the code when the page loaded, and not when it should have, after you typed into the fields and pressed submit.
0
 
lazzydogAuthor Commented:
Yup that's exactly what I did.  You know, I created a test page with just two text boxes CRFirstName, and CRLastName, tested it and it worked. I'm thinking there's must be an error somewhere in my code.  And I can't figure out what it is, maybe I'll just rebuild the whole page again.  Gosh...that's goining to take alot of time.  Thanks so much for your help.
0
 
trainsdseCommented:
You're welcome.  If you need help with another thing like the html, just create a new question and we can start over :)

Thomas
trainsdse@hotmail.com
0
 
lazzydogAuthor Commented:
hey compuken,
I just want to thank you for trying to help me all along.  
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 9
  • 8
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now