1 / 9

ADO Add

ADO Add. Y.-H. Chen International College Ming-Chuan University Fall, 2004. ADO Add Records. We may use the SQL INSERT INTO command to add a record to a table in a database. Add a Record to a Table in a Database. Add a Record to a Table in a Database.

lydia-olsen
Download Presentation

ADO Add

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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.

More Related