Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 12th, 2005, 10:15 AM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default HELP ME to add a record to a database using ASP

hello

I am newbie and in the process of learning ASP and database.

I want to learn how to add/delete/update/..etc records in databases using ASP.

from the following site:
http://www.w3schools.com/ado/default.asp

I copied a code to add record to a database.

On my pc:
Using MS Access 2003, I have created a database called 'basics.mdb' and the table name is 'basics_table'. I modified the code according to my database path and table.

There is the ASP code:

<html>
<body>

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/database/basics.mdb"

sql="INSERT INTO basics_table (CustomerID,CompanyName,"
sql=sql & "ContactName,Address,City,PostalCode,Country)"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("custid") & "',"
sql=sql & "'" & Request.Form("compname") & "',"
sql=sql & "'" & Request.Form("contname") & "',"
sql=sql & "'" & Request.Form("address") & "',"
sql=sql & "'" & Request.Form("city") & "',"
sql=sql & "'" & Request.Form("postcode") & "',"
sql=sql & "'" & Request.Form("country") & "')"

on error resume next
conn.Execute sql,recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
%>

</body>
</html>





and there is the html code:

<html>
<body><form method="post" action="disbas_add.asp">
<table>
<tr>
<td>CustomerID:</td>
<td><input name="custid"></td>
</tr><tr>
<td>Company Name:</td>
<td><input name="compname"></td>
</tr><tr>
<td>Contact Name:</td>
<td><input name="contname"></td>
</tr><tr>
<td>Address:</td>
<td><input name="address"></td>
</tr><tr>
<td>City:</td>
<td><input name="city"></td>
</tr><tr>
<td>Postal Code:</td>
<td><input name="postcode"></td>
</tr><tr>
<td>Country:</td>
<td><input name="country"></td>
</tr>
</table>
<br /><br />
<input type="submit" value="Add New">
<input type="reset" value="Cancel">
</form></body>
</html>


the problem is that whenever I try to add a record it doesn't work and I get the following msg: 'No update permissions !'

Can anybody help me please to solve this problem and understand it ?
Reply With Quote
  #2 (permalink)  
Old August 15th, 2005, 05:26 PM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Hi,

Can you comment the following line and paste the exact error u r getting:
on error resume next

Om Prakash
Reply With Quote
  #3 (permalink)  
Old August 16th, 2005, 07:42 PM
Friend of Wrox
Points: 2,101, Level: 18
Points: 2,101, Level: 18 Points: 2,101, Level: 18 Points: 2,101, Level: 18
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Make sure your web user has write permissions to the Access file.

Check it out.

Reply With Quote
  #4 (permalink)  
Old August 18th, 2005, 05:33 AM
Authorized User
 
Join Date: Jan 2005
Location: Mumbai, Maharashtra, India.
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to askenkray
Default

Dont copy code before you understand it.It is very simple.You can add/delete/Edit/Update records alll on one page.

Just try to understand the logic

Ashwin S.Kenkare
Programmer
CMI
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Add New Record and Get ID omninewt Classic ASP Databases 5 April 10th, 2008 12:20 PM
ASP.NET 2.0 Updating Database Record columth06 ASP.NET 2.0 Basics 0 November 4th, 2006 07:43 AM
ASP program How to add new ID for new record kinshuk SQL Server ASP 3 March 21st, 2005 02:43 PM
ASP to add to Database gilgalbiblewheel Classic ASP Databases 7 September 3rd, 2004 06:43 PM
Add new record in SQL Server database bhatnagar_shaily Classic ASP Components 3 September 24th, 2003 01:16 AM



All times are GMT -4. The time now is 10:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.