Solved

add new record.

Posted on 2004-04-10
1
149 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 49

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

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 …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
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…

746 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

12 Experts available now in Live!

Get 1:1 Help Now