100 likes | 168 Views
ADDING A RECORD. A) What are we going to do? ADD: 1-datagir.asp 2-dataveritabani.asp B) Design your page C) Create your database a. Access File Name: db341.mdb b. Table Name: member c: Field Names: member( memID , memName, memSurname, memAddress). A). Name:. Surname:. Address:.
E N D
ADDING A RECORD A) What are we going to do? ADD: 1-datagir.asp 2-dataveritabani.asp B) Design your page C) Create your database a. Access File Name: db341.mdb b. Table Name: member c: Field Names: member(memID, memName, memSurname, memAddress) A) Name: Surname: Address: Submit dataveritabani.asp datagir.asp
ADDING A RECORD B) INSERT / FORM Name Address Sexuality Hobbies Select from a list Which one? PAGE DESIGN IN FRONTPAGE dataveritabani.asp datagir.asp
ADDING A RECORD C) DATABASE DESIGN IN ACCESS Access File Name: db341.mdb
ADDING A RECORD- datagir.asp dataveritabani.asp These lines must be deleted It is better to change according to the related field name of the table
ADDING A RECORD- dataveritabani.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 %>
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- dataveritabani.aspDatabase Connection <% set conn341 = Server.CreateObject("ADODB.Connection") conn341.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db341.mdb")) %>
ADDING A RECORD - dataveritabani.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 “.........”
ADDING A RECORD - dataveritabani.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. Cursor Type it controls the recordset for user operations (Add,Delete,Update) Lock Type it locks the database record while updating program code. rs.close set rs = nothing Close it closes open recorset object and depended objects on recordset Nothing it releases the connection object
ADDING A RECORD - dataveritabani.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