?
Solved

add new record.

Posted on 2004-04-10
1
Medium Priority
?
156 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 400 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

7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

762 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