Solved

add new record.

Posted on 2004-04-10
1
153 Views
Last Modified: 2011-09-20
sorry i realized that i did not have the file included. I was so sure i included that file that i blindly copy pasted the code.   lol


just one more thing if you can help me. Basically this is a project me and my friend are working on and one of the pages is suppose to add new record to the database. i don't know it will not update it. I put values in the form and then it just clears the field but it does not add the record to the database.



<%Option Explicit%>
<!--#include virtual="/adovbs.inc"-->
<html>
<head>
<title>
</title>
</head>
<body bgcolor="#000066">

<H1 align=center><font color="blue">Registration</font></h1>

<form action="register.asp" method="post" >
<h2><font color="blue">Name:</font> <input type="text" name="nam" size=20>
<h2><font color="blue">Phone: </font><input type="text" name="pho" size=10>
<h2><font color="blue">Pin:</font> <input type="text" name="pinn" size=3><sub><font color="red">(*Optional)</font></sub>
<h2><font color="blue">Choose Plan:</font> <select name="plan">
<option selected> Student          $20.00 on the card
<option>Normal           $50.00 on the card
<option>Business          $100.00 on the card
</option>
</select>
<input type="submit" name="submit" value=" Submit ">
</form>

 





<%

 If request.form("submit")="Submit" then

Dim rs, sql, conn



      set conn= createobject("ADODB.Connection")


      conn.open "int213db"


      sql="Select * From abcTel where 1<> 1"

         
      Set rs = server.createobject("Adodb.recordset")
      
      
      rs.open "abcTel",  conn, adopenstatic, adlockoptimistic

      rs.addnew
      rs("client_name") = request.form("nam")
      rs("client_phone_number") = request.form("pho")
      rs("card_pin") = request.form("pinn")
      rs("card_plan_name") = request.form("plan")
      rs.update
      
 









rs.close
set rs=nothing
conn.close
set conn=nothing


end if
%>        
</body>
</html>


0
Comment
Question by:punjabijatt
1 Comment
 
LVL 51

Accepted Solution

by:
Ryan Chong earned 100 total points
ID: 10796805
Try change:

rs.open "abcTel",  conn, adopenstatic, adlockoptimistic

to:

rs.open sql,  conn, adopenstatic, adlockoptimistic

?

or try this instead:

<%
 If request.form("submit")="Submit" then

Dim rs, sql, conn
     set conn= createobject("ADODB.Connection")

     conn.open "int213db"

sql="Insert into abcTel (" & _
     "client_name, client_phone_number, card_pin, card_plan_name " & _
     ") values (" & _
     "'" & request.form("nam") & "', '" & request.form("pho") & "', '" & request.form("pinn") & "', '" & request.form("plan") & "' " & _
     ") "
conn.execute sql
     
conn.close
set conn=nothing

end if
%>        

For the correct syntax to establish a connection, refer to:
http://www.connectionstrings.com
http://www.able-consulting.com/ADO_Conn.htm
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 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