% Dim Msg, Grid, sSQL, Cmd dim t_fname, t_lname, strTable Init Set Grid = New GridProcess Grid.Conn = Cn Grid.Title = "" Grid.Table = strTable Grid.KeyFld = "ArtistID" Grid.FldName = array("ArtistID", "ArtistFName" , "ArtistLName",strlinks) Grid.FldSortBy = array("ArtistID", "FirstName", "LastName","") Grid.FldHead = array("", "First name", "Last name","") Grid.FldDefault= array("", "", "","") Grid.FldType = array("I", "T", "T","") Grid.FldFormat = array("", "", "","") Grid.FldAlign = array("L", "L", "L","L") Grid.FldEdit = array(0,1,1,0) Grid.FldInsert = array(0,1,1,0) Grid.FldDisp = array(0,1,1,1) Grid.FldSort = array(0,1,1,0) Grid.FldSize = array(0,15,15,15) Grid.FldMaxLen = array(0,50,50,50) Grid.FldWidth = array(0,105,105,105) Grid.HiddenFld = array("t_fname", "t_lname") Grid.HiddenVal = array(t_fname, t_lname) Grid.ImageLoc = "../Images/" Grid.PageSize = 15 Grid.ShowCount = 1 Grid.EditPos = "R" if admin() then Grid.AddMode = 1 Grid.EditMode = 1 Grid.DelMode = 1 else Grid.AddMode = 1 Grid.EditMode = 1 Grid.DelMode = 1 end if sub Init t_fname = request("t_fname") & "" t_lname = request("t_lname") & "" strTable = "Artists where ArtistID > 0" if t_fname <> "" then strTable = strTable & " and ArtistFName like '" & replace(t_fname,"'","''") & "%'" if t_lname <> "" then strTable = strTable & " and ArtistLName like '" & replace(t_lname,"'","''") & "%'" end sub function strlinks() strlinks= "'Artworks'" end function if Request.Form ("DeleteID") & "" <> "" then Cn.Execute "Delete from Artists where ArtistID = " & Request.Form ("DeleteID") if Err <> 0 then Msg = Err.description else response.redirect "Artist.asp?t_fname=" & t_fname & "&t_lname=" & t_lname end if elseif Request.Form ("SaveID") & "" <> "" then dim ID, ArtistFName, ArtistLName ID = Request.Form("SaveID") ArtistFName = request("ArtistFName") & "" ArtistLName = request("ArtistLName") & "" if Validate() then set cmd = Server.CreateObject("ADODB.Command") Cmd.ActiveConnection = Cn Cmd.Parameters.Append Cmd.CreateParameter(,adVarchar, ,50, ArtistFName) Cmd.Parameters.Append Cmd.CreateParameter(,adVarchar, ,50, ArtistLName) if ID = "0" then sSQL = "INSERT into Artists (ArtistFName, ArtistLName) " & _ " values('"&ArtistFName&"','"&ArtistLName&"')" else sSQL = "UPDATE Artists SET ArtistFName=?, ArtistLName=?" & _ " WHERE ArtistID = " & ID end if 'Cmd.CommandText = sSQL 'response.write sSQL 'response.End() 'Cmd.Execute cn.execute sSQL set cmd = nothing if Err <> 0 then Grid.SaveError = True Msg = Err.description else response.redirect "Artist.asp?t_fname=" & t_fname & "&t_lname=" & t_lname end if else Grid.SaveError = True end if end if function Validate Validate = true end function %>