%@ CodePage = 1254 LCID = 1055 %> <% Response.expires = 0 Response.expiresabsolute = Now() - 1 Response.addHeader "pragma", "no-cache" Response.addHeader "cache-control", "private" Response.addHeader "cache-control", "no-cache" Response.addHeader "cache-control", "no-store" Response.CacheControl = "no-cache" %> <% If Not IsLoggedIn Then Response.Redirect "login.asp" %> <% ' Initialize common variables x_id = Null: ox_id = Null: z_id = Null x_yazi = Null: ox_yazi = Null: z_yazi = Null %> <% Response.Buffer = True ' Load key from QueryString x_id = Request.QueryString("id") ' Get action sAction = Request.Form("a_edit") If sAction = "" Or IsNull(sAction) Then sAction = "I" ' Display with input box Else ' Get fields from form x_id = Request.Form("x_id") x_yazi = Request.Form("x_yazi") End If ' Check if valid key If x_id = "" Or IsNull(x_id) Then Response.Redirect "kayan_yazilist.asp" ' Open connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str Select Case sAction Case "I": ' Get a record to display If Not LoadData() Then ' Load Record based on key Session(ewSessionMessage) = "Kayıt Bulunmadı" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "kayan_yazilist.asp" End If Case "U": ' Update If EditData() Then ' Update Record based on key Session(ewSessionMessage) = "Başarıyla Güncelleştirildi" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "kayan_yazilist.asp" End If End Select %>
Değiştir TABLO: kayan yazi
Listeye Geri Don
<%= Session(ewSessionMessage) %>
<% Session(ewSessionMessage) = "" ' Clear message End If %> <% conn.Close ' Close Connection Set conn = Nothing %> <% '------------------------------------------------------------------------------- ' Function LoadData ' - Load Data based on Key Value ' - Variables setup: field variables Function LoadData() Dim rs, sSql, sFilter sFilter = ewSqlKeyWhere sFilter = Replace(sFilter, "@id", AdjustSql(x_id)) ' Replace key value sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, sFilter, "") Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sSql, conn If rs.Eof Then LoadData = False Else LoadData = True rs.MoveFirst ' Get the field contents x_id = rs("id") x_yazi = rs("yazi") End If rs.Close Set rs = Nothing End Function %> <% '------------------------------------------------------------------------------- ' Function EditData ' - Edit Data based on Key Value ' - Variables used: field variables Function EditData() On Error Resume Next Dim rs, sSql, sFilter sFilter = ewSqlKeyWhere sFilter = Replace(sFilter, "@id", AdjustSql(x_id)) ' Replace key value sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, sFilter, "") Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 3 rs.Open sSql, conn, 1, 2 If Err.Number <> 0 Then Session(ewSessionMessage) = Err.Description rs.Close Set rs = Nothing EditData = False Exit Function End If ' clone old and new rs object Dim rsold, rsnew Set rsold = rs.Clone(1) rsold.Requery() Set rsnew = rs.Clone(1) If rs.Eof Then EditData = False ' Update Failed Else ' Field id ' Field yazi sTmp = Trim(x_yazi) If Trim(sTmp) = "" Then sTmp = Null rs("yazi") = sTmp ' Call updating event If Recordset_Updating(rs, rsnew) Then rs.Update If Err.Number <> 0 Then Session(ewSessionMessage) = Err.Description EditData = False Else EditData = True End If Else rs.CancelUpdate EditData = False End If End If ' Call updated event If EditData Then Call Recordset_Updated(rsold, rsnew) End If rs.Close Set rs = Nothing rsold.Close Set rsold = Nothing rsnew.Close Set rsnew = Nothing End Function '------------------------------------------------------------------------------- ' Recordset updating event Function Recordset_Updating(rsold, rsnew) On Error Resume Next ' Please enter your customized codes here Recordset_Updating = True End Function '------------------------------------------------------------------------------- ' Recordset updated event Sub Recordset_Updated(rsold, rsnew) On Error Resume Next End Sub %>