1 / 13

Database Application: Creating Tables and Adding Members

In today's lab, we will create a database and a simple data form to add members to the member table. We will use ADO objects to establish a database connection, create a recordset object, and save the registration date and IP number of each guest.

dshaffer
Download Presentation

Database Application: Creating Tables and Adding Members

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. Today, We are going to finish our password files and add members to the member table in our database Objectives: Creating the database to be used in lab application Designing a simple data form Defining Road Map Using some ADO Objects Understanding Connection Variables How to create database connection How to create recordset object Using some ADO RecordSet Methods AddNew Update Saving registration date of a guest Taking IP number of a guest

  2. a Database Application • What are we going to do? • Design/Create your database • a. Access File Name: db341.mdb • b. Table Name: member • c: Field Names: member(memID, memName, memSurname, memAddress) • C) Design your pages and road map • ADD: 1-dataadd.asp 2-dataadddb.asp • We are going to record our members to a database • Database in Access Access File Name: db341.mdb

  3. ADDING A RECORD C) Web Pages and the road map ADD: 1-dataadd.asp 2-dataadddb.asp Name: Your record has been entered successfully Surname: Address: Submit dataadddb.asp dataadd.asp

  4. ADDING A RECORD INSERT / FORM Name Address Sexuality Hobbies Select from a list Which one? PAGE DESIGN IN FRONTPAGE Dataadddb.asp dataadd.asp

  5. ADDING A RECORD- dataadd.asp dataadddb.asp These lines must be deleted It is better to change according to the related field name of the table

  6. ADDING A RECORD- dataadddb.asp • Create Connection (bağlantı kur –dbbaglanti.txt) • ‘Process (aspekle.txt) • Close Connection (bağlantı kapat –dbbaglanti.txt) <% set conn341 = Server.CreateObject("ADODB.Connection") conn341.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db341.mdb")) ‘ASPEKLE.TXT conn341.Close Set conn341 = Nothing %>

  7. It is used to create a database connection Driver  MS Access Database DBQ  Determines File Position Server.MapPath File name must be local and absolute. But it creates some problems. Server.MapPath converts relative address to a absolute address. ADO requires these 2 information ADDING A RECORD- dataadddb.aspDatabase Connection <% set conn341 = Server.CreateObject("ADODB.Connection") conn341.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db341.mdb")) %>

  8. ADDING A RECORD- dataadddb.aspCreating a RecordSet The recordset object contains a copy of records—all or some. The set of records has a beginning and end. The beginning/The end ismarked by a set of characters, referred to as Beginning of File (BOF) End of File (EOF) Do While Not RecordSet.EOF ‘Do something… RecordSet.MoveNext Loop

  9. ADDING A RECORD - dataadddb.asp Creating a RecordSet – aspekle.txt Set kayitseti = server. CreateObject("ADODB.Recordset") kayitseti.Open "kayit", conn341 , 1 , 3 kayitseti.AddNew kayitseti("kayitTar")=Day(now())& "/" &Month(now())& "/" &Year(now())& " “& FormatDateTime(now(),3) kayitseti("kayitIP")=Request.ServerVariables("REMOTE_ADDR") kayitseti.update kayitseti.close set kayitseti = nothing Response.Write “.........”

  10. ADDING A RECORD - dataadddb.asp Creating a RecordSet – aspekle.txt rs.open “table_name”, connection_name, Cursor_Type, Lock_Type Open  it enables the recordset ready in order to access data. Close  it closes open recorset object and depended objects on recordset Nothing  it releases the connection object rs.close set rs = nothing

  11. ADDING A RECORD - dataadddb.asp Creating a RecordSet – aspekle.txt Create the connection Create the recordset rs1(“memName”) = request.form(“txtmemName”) rs1(“memSurname”) = request.form(“txtmemSurname”) rs1(“memAddress”) = request.form(“txtmemAddress”) rs1(“memRecordDate”) = Day(now()) & “/ ” & Month(now()) & “/ “ & Year(now()) & “ “ FormatDateTime(now(),3) rs1(“memRecordIP”) = Server.RequestVariables(“REMOTE_ADDR”) Adding a Record Close the Recordset Close the Connection

  12. ADDING A RECORD – date formats quick review

  13. ADDING A RECORD - dataadddb.asp

More Related