ADO Add - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

ADO Add

Description:

If the table contains a primary key, make sure to append a unique, non-Null ... That is because the system might see you as an anonymous internet user when you ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 10
Provided by: yenhun
Category:
Tags: ado | add | make | run | up

less

Transcript and Presenter's Notes

Title: ADO Add


1
ADO Add
  • Y.-H. Chen
  • International College
  • Ming-Chuan University
  • Fall, 2004

2
ADO Add Records
  • We may use the SQL INSERT INTO command to add a
    record to a table in a database.

3
Add a Record to a Table in a Database
4
Add a Record to a Table in a Database
  • We want to add a new record to the Customers
    table in the Northwind database. We first create
    a form that contains the fields we want to
    collect data from.
  • When the user presses the submit button the form
    is sent to a file called "demo_add.asp". The
    "demo_add.asp" file contains the code that will
    add a new record to the Customers table.

5
Add a Record to a Table in a Database
6
Important
  • If you use the SQL INSERT command be aware of the
    following
  • If the table contains a primary key, make sure to
    append a unique, non-Null value to the primary
    key field (if not, the provider may not append
    the record, or an error occurs)
  • If the table contains an AutoNumber field, do not
    include this field in the SQL INSERT command (the
    value of this field will be taken care of
    automatically by the provider)

7
What about Fields With no Data?
  • In a MS Access database, you can enter
    zero-length strings ("") in Text, Hyperlink, and
    Memo fields IF you set the AllowZeroLength
    property to Yes.
  • Note Not all databases support zero-length
    strings and may cause an error when a record with
    blank fields is added. It is important to check
    what data types your database supports.

8
Read this First
  • If you try to update the database, you will get
    the error message "You do not have permission to
    update this database". You get this error because
    you don't have write access to our server.
  • BUT, if you copy the code and run it on your own
    system, you might get the same error. That is
    because the system might see you as an anonymous
    internet user when you access the file via your
    browser. In that case, you have to change the
    access-rights to get access to the file.

9
How to change the access-rights of your Access
database?
  • Open Windows Explorer, find the .mdb file.
    Right-click on the .mdb file and select
    Properties. Go to the Security tab and set the
    access-rights here.
Write a Comment
User Comments (0)
About PowerShow.com