Wrox Programmer Forums
|
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 11th, 2005, 11:54 PM
Registered User
 
Join Date: Feb 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to neal_rainman
Default Help me!!!!!!!


--------------------------------------------------------------------------------

trying to do a search page coding but everytime giving this following error please help me out---

Microsoft OLE DB provider for SQL Server error '80040e14'

invalid cloumn name ' , '.

/apps/./ins/utils.asp, line 1092



and my code---
sSQL = replace(sSQL,"[037PERCENT]","%")
   sSQL = ESCAPESQL(sSQL)
   Set RecordSet = Server.CreateObject("ADODB.Recordset")
   RecordSet.PageSize = iPageSize
   RecordSet.CacheSize = iPageSize
   RecordSet.CursorLocation = iCursorLocation
   RecordSet.CursorType = 3
   Recordset.Open sSQL, Conn, 3, 1, &H0001

1092 line is ===> Recordset.Open sSQL, Conn, 3, 1, &H0001
 
Old February 14th, 2005, 12:31 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

The problem is with the query in sSQL. You may print it to browser and check it. Could you please do it so that we can see the query ?
 
Old February 14th, 2005, 06:03 PM
Registered User
 
Join Date: Feb 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to neal_rainman
Default

still cant find any problem....this is the thing happening my page is setup up to show 25 records per page after doing search its genrate per page moe then 25 and its totally fine upto now i can see first page second page when i try to search third page it shows the error its not only third page though its something third time suppose it generate 25 page per page 25 records any page upto second time is ok i can see my data...but when i click third time it shows the error--

Microsoft OLE DB provider for SQL Server error '80040e14'

invalid cloumn name ' , '.

/apps/./ins/utils.asp, line 1092



jbenson001
Junior Member



USA
164 Posts
 Posted - 02/13/2005 : 06:22:45 AM


--------------------------------------------------------------------------------

A bit strange. Can you please show me what the value of sSQL is?


neal_rainman
Starting Member



4 Posts
 Posted - 02/13/2005 : 8:15:41 PM


--------------------------------------------------------------------------------

here you go i m posting my whole page of coding --- please look at it --



<%
g_bInWindow=Uploader.Form("InWindow") & Uploader.Form("InWindow2")

'// Convert Date/Time to 6,8 or 12 digit format.
function GetDate(sDate,iType,sSeperator,sTSeperator1,sTSepe rator2)
  Dim dd,mm,yyyy,hh,nn, iFormat
  iFormat = g_iFormat
  if (sDate<>"NOW") then
     if (IsNull(RecordSet(sDate))) then
        GetDate=""
        exit function
     end if
     dd = cStr(Day(RecordSet(sDate)))
     mm = cStr(Month(RecordSet(sDate)))
     yyyy = cStr(Year(RecordSet(sDate)))
     hh = CStr(Hour(RecordSet(sDate)))
     nn = CStr(Minute(RecordSet(sDate)))
  else
     dd = cStr(Day(Now()))
     mm = cStr(Month(Now()))
     yyyy = cStr(Year(Now()))
     hh = CStr(Hour(Now()))
     nn = CStr(Minute(Now()))
  end if
  if Len(dd)=1 then
     dd="0" & dd
  end if
  if Len(mm)=1 then
     mm="0" & mm
  end if
  if Len(hh)=1 then
     hh="0" & hh
  end if
  if Len(nn)=1 then
     nn="0" & nn
  end if
  if (iFormat=0) then
     if (iType=0) then
        GetDate="" + mm + sSeperator + dd + sSeperator + yyyy
     elseif (iType=1) then
        GetDate="" + hh + sTSeperator2 + nn
     elseif (iType=2) then
        GetDate="" + mm + sSeperator + dd + sSeperator + yyyy + sTSeperator1 + hh + sTSeperator2 + nn
     end if
  elseif (iFormat=1) then
     if (iType=0) then
        GetDate="" + dd + sSeperator + mm + sSeperator + yyyy
     elseif (iType=1) then
        GetDate="" + hh + sTSeperator2 + nn
     elseif (iType=2) then
        GetDate="" + dd + sSeperator + mm + sSeperator + yyyy + sTSeperator1 + hh + sTSeperator2 + nn
     end if
  elseif (iFormat=2) then
     if (iType=0) then
        GetDate="" + yyyy + sSeperator + mm + sSeperator + dd
     elseif (iType=1) then
        GetDate="" + hh + sTSeperator2 + nn
     elseif (iType=2) then
        GetDate="" + yyyy + sSeperator + mm + sSeperator + dd + sTSeperator1 + hh + sTSeperator2 + nn
     end if
  end if
end function

'// Expand 4/8/12 character date format.
function ProcessDate(sValue)
  Dim sDate,sTime,iFormat
  Dim sDay,sMonth,sYear
  Dim iDF,iDBDF
  Dim sTemp
  sDate=""
  sTime=""
  iDF=0
  iDBDF=0
  if (sValue="") then
     ProcessDate="Null"
     exit function
  end if
  if (Len(sValue)>=8) then
     if (iDF=0) then
       sMonth = Mid(CHECKNULL(sValue),1,2)
       sDay = Mid(CHECKNULL(sValue),3,2)
       sYear = Mid(CHECKNULL(sValue),5,4)
     elseif (iDF=1) then
       sDay = Mid(CHECKNULL(sValue),1,2)
       sMonth = Mid(CHECKNULL(sValue),3,2)
       sYear = Mid(CHECKNULL(sValue),5,4)
     elseif (iDF=2) then
       sYear = Mid(CHECKNULL(sValue),1,4)
       sMonth = Mid(CHECKNULL(sValue),5,2)
       sDay = Mid(CHECKNULL(sValue),7,2)
     end if
     if (iDBDF=0) then
       sDate=sMonth & "/" & sDay & "/" & sYear
     elseif (iDBDF=1) then
       sDate=sDay & "/" & sMonth & "/" & sYear
     elseif (iDBDF=2) then
       sDate=sYear & "/" & sMonth & "/" & sDay
     end if
  end if
  if (Len(sValue)=12) then
     sTime=Mid(CHECKNULL(sValue),9,2) & ":" & Mid(CHECKNULL(sValue),11,2)
  elseif (Len(sValue)=4) then
     sTime=Mid(CHECKNULL(sValue),1,2) & ":" & Mid(CHECKNULL(sValue),3,2)
  end if
  sTemp="'"
  sTemp=sTemp & sDate & " " & sTime
  sTemp=Trim(sTemp) & "'"
  if Trim(sDate )="" and Trim(sTime)="" then
     sTemp="NULL"
  end if
  ProcessDate=sTemp
end function

function ProcessDate2(sValue)
  Dim sDate,sTime,iFormat
  Dim sDay,sMonth,sYear
  Dim iDF,iDBDF
  Dim sTemp
  sDate=""
  sTime=""
  iDF=0
  iDBDF=0
  if (sValue="") then
     ProcessDate2="Null"
     exit function
  end if
  if (Len(sValue)>=8) then
     if (iDF=0) then
       sMonth = Mid(CHECKNULL(sValue),1,2)
       sDay = Mid(CHECKNULL(sValue),3,2)
       sYear = Mid(CHECKNULL(sValue),5,4)
     elseif (iDF=1) then
       sDay = Mid(CHECKNULL(sValue),1,2)
       sMonth = Mid(CHECKNULL(sValue),3,2)
       sYear = Mid(CHECKNULL(sValue),5,4)
     elseif (iDF=2) then
       sYear = Mid(CHECKNULL(sValue),1,4)
       sMonth = Mid(CHECKNULL(sValue),5,2)
       sDay = Mid(CHECKNULL(sValue),7,2)
     end if

     if sMonth>=1 and sMonth<=12 then
        sMonth = MonthName(sMonth,True)
     end if

     if (iDBDF=0) then
       sDate=sMonth & "/" & sDay & "/" & sYear
     elseif (iDBDF=1) then
       sDate=sDay & "/" & sMonth & "/" & sYear
     elseif (iDBDF=2) then
       sDate=sYear & "/" & sMonth & "/" & sDay
     end if
  end if
  if (Len(sValue)=12) then
     sTime=Mid(CHECKNULL(sValue),9,2) & ":" & Mid(CHECKNULL(sValue),11,2)
  elseif (Len(sValue)=4) then
     sTime=Mid(CHECKNULL(sValue),1,2) & ":" & Mid(CHECKNULL(sValue),3,2)
  end if
  sTemp=sTemp & sDate & " " & sTime
  if Trim(sDate )="" and Trim(sTime)="" then
     sTemp="NULL"
  end if
  ProcessDate2=sTemp
end function

'// Convert to String, return "" if Null.
function CStrNull(sValue)
   if (IsNull (sValue)) then
       sValue=""
   else
       sValue=CStr(sValue)
   end if
   CStrNull=sValue
end function

'// Replace Double Quote with HTML version.
function FixedData(sValue)
   FixedData=replace(sValue,chr(34),"&quot;")
end function

sub CreateDataPageSubForms (g_ScriptName,g_sMode,g_HasDetailForm)
   ' frmRefresh
   response.write "<form name=""frmRefresh"" method=""post"" enctype=""multipart/form-data"" action=""" & g_ScriptName & """>"
   for each item in Uploader.mcolFormElem
      response.write "<input type=""hidden"" name=""" & Item & """ value=""" & Uploader.Form(item) & """>"
   next
   response.write "</form>"

   'frmFindRecord
   response.write "<form name=""frmFindRecord"" id=""frmFindRecord"" enctype=""multipart/form-data"" method=""post"" target=""_searchWindow"">"
   response.write "<input type=""hidden"" name=""Lookup"" value=""1"">"
   response.write "<input type=""hidden"" name=""InWindow"" value=""1"">"
   response.write "<input type=""hidden"" name=""refReturnFieldCode"" value="""">"
   response.write "<input type=""hidden"" name=""refReturnFieldDesc"" value="""">"
   response.write "<input type=""hidden"" name=""refTable"" value="""">"
   response.write "<input type=""hidden"" name=""refCodeValue"" value="""">"
   response.write "<input type=""hidden"" name=""refDescValue"" value="""">"
   response.write "<input type=""hidden"" name=""refField"" value=""1"">"
   response.write "<input type=""hidden"" name=""refFieldName"" value="""">"
   response.write "<input type=""hidden"" name=""refUpdateField"" value="""">"
   response.write "<input type=""hidden"" name=""refDataType"" value="""">"
   response.write "</form>"

   'frmRedrawDropdown
   response.write "<form name=""frmRedrawDropdown"" id=""frmRedrawDropdown"" enctype=""multipart/form-data"" method=""post"" target=""_redrawWindow"" action=""redraw.asp"">"
   response.write "<input type=""hidden"" name=""dropdownFieldRef"" value="""">"
   response.write "<input type=""hidden"" name=""dropdownFieldValue"" value="""">"
   response.write "</form>"

   'frmSearch
   response.write "<form method=""POST"" name=""frmSearch"" enctype=""multipart/form-data"" action=""searchdata.asp"">"
   for each item in Uploader.mcolFormElem
      if Mid(item,1,7)="Srch571" then
         response.write "<input type=""hidden"" name=""" & Mid(item,8) & """ value=""" & Uploader.Form(item) & """>"
      end if
   next
   response.write "</form>"
end sub

function DeleteSelectedRecord(Conn,sTable,sWhere,g_Status1, g_Status2,g_CloseWindow)
  Dim sSQL
  Dim iError

  response.write "<br><br><br><center><table width=""80%"" border=""1"" bgColor=""#000000"" cellpadding=""5"" cellspacing=""5""><tr><td bgColor=""#FFFFFF"">"
  if (sWhere<>"") then
     sSQL = "DELETE FROM " & CheckSpace(sTable) & " WHERE " & ESCAPESQL(sWhere)
     set RecordSet = Conn.execute(sSQL)

     response.write "<script language=""JavaScript"" type=""text/javascript"">refreshParentWindow();</script>"
     iError = Err.Number
     if (iError<>0) then
       response.write "<div class=""fieldPrompt""><center>" & g_Status1 & ": <br><br>" & Err.Description & "</center></div> "
     else
       response.write "<div class=""fieldPrompt""><center>" & g_Status2 & ".</center></div> "
     end if
     DeleteSelectedRecord = iError
  else
     response.write "<div class=""fieldPrompt""><center>No record selected to delete.</center></div> "
     DeleteSelectedRecord = -1
  end if
  response.write "</td></tr></table><br><br>"
  response.write "<center><input type=""button"" class=""bigbuttonColor"" id=""Button8"" name=""btnReturn"" onClick=""window.close();"" value=""" & g_CloseWindow & """></center>"
  response.end
end function

function EditSelectedRecord(g_ScriptName,g_sMode,Conn,Recor dSet,g_LinkField,g_EditOwnRecords,bReportMode,bRea dOnly,sSQL,sRSSQL,g_TableName,g_WhereClause,g_Curs orLocation,g_TextBoxHighlightColor,g_NoMatchingDat a,g_SearchPage,g_SearchAgain,iTotalPages,g_NextRec ord,g_PrevRecord,g_FirstRecord,g_LastRecord,g_Line Index,sLineWhere,iMode)
  if (g_LinkField<>"") and (g_EditOwnRecords<>0) and (bReadOnly=False) then
    sSQL = "SELECT " & g_LinkField & " FROM "+ CheckSpace(g_TableName) +" WHERE " & ESCAPESQL(g_WhereClause)
    set RecordSet = Conn.execute(sSQL)
    if (RecordSet(g_LinkField) <> Session("UserID")) then
       bReadOnly=True
    end if
  end if
  sSQL = "SELECT " & g_FieldSelect & " FROM "+ CheckSpace(g_TableName) +" WHERE " & ESCAPESQL(g_WhereClause)
  set RecordSet = Conn.execute(sSQL)
  sRSSQL=sSQL
  EditSelectedRecord = Err.Number
  if (Err.Number<>0) then
     response.end
  end if

end function


function ProcessViewMode(g_ScriptName,g_sMode,Conn,RecordSe t,g_LinkField,g_EditOwnRecords,bReportMode,bReadOn ly,sSQL,sRSSQL,g_TableName,g_WhereClause,g_CursorL ocation,g_TextBoxHighlightColor,g_NoMatchingData,g _SearchPage,g_SearchAgain,iTotalPages,g_NextRecord ,g_PrevRecord,g_FirstRecord,g_LastRecord,g_LineInd ex,sLineWhere,iMode)
  Dim iLeftB
  Dim iRightB
  Dim sField

  if (Uploader.Form("SQL")<>"") then
     if (Uploader.Form("SQL")<>"") then
        sSQL=(Uploader.Form("SQL"))
     end if
     sSQL = ESCAPESQL(sSQL)
     sRSSQL=sSQL
     Set RecordSet = Server.CreateObject("ADODB.Recordset")
     RecordSet.PageSize = 1
     RecordSet.CacheSize = 1
     RecordSet.CursorLocation = g_CursorLocation
     RecordSet.CursorType = 3
     Recordset.Open sSQL, Conn, 3, 1, &H0001
     if (Recordset.eof) then
        NoMatchingDataWarning g_TextBoxHighlightColor,g_NoMatchingData,g_SearchP age,g_SearchAgain
        response.end
     end if
      iTotalPages=Trim(CLng(RecordSet.PageCount))
      if (Uploader.Form("btnPage")=g_NextRecord) then
        iPage=Clng(Uploader.Form("Page"))
        iPage=iPage+1
     elseif (Uploader.Form("btnPage")=g_PrevRecord) then
        iPage=Clng(Uploader.Form("Page"))
        iPage=iPage-1
     elseif (Uploader.Form("btnPage")=g_FirstRecord) then
        iPage=Clng(1)
     elseif (Uploader.Form("btnPage")=g_LastRecord) then
        iPage=CLng(iTotalPages)
     else
        iPage=1
     end if
     RecordSet.AbsolutePage = iPage
     bReportMode=True
     iMode=1

     sLineWhere=""
     iLeftB=InStr(g_LineIndex,"[")
     iRightB=InStr(g_LineIndex,"]")
     while iLeftB>0 and iRightB>0
       if (sLineWhere<>"") then
          sLineWhere=sLineWhere+" AND "
       end if
       sField=Mid(g_LineIndex,iLeftB+2,(iRightB-(iLeftB+2)))
       if (Mid(g_LineIndex,iLeftB+1,1)="0") then
          sLineWhere = sLineWhere & CheckSpace(sField) & " = " & RecordSet(sField)
       elseif (Mid(g_LineIndex,iLeftB+1,1)="1") then
          sLineWhere = sLineWhere&CheckSpace(sField) & " = " & "[039SGLQUOT]" & RecordSet(sField) & "[039SGLQUOT]"
       else
          sDelimiterPrefix = g_DateDelimiterPrefix
          sDelimiterPrefix = replace(sDelimiterPrefix,"#","[035HASH]")
          sDelimiterPrefix = replace(sDelimiterPrefix,"'","[039SGLQUOT]")
          sDelimiterSuffix = g_DateDelimiterSuffix
          sDelimiterSuffix = replace(sDelimiterSuffix,"#","[035HASH]")
          sDelimiterSuffix = replace(sDelimiterSuffix,"'","[039SGLQUOT]")
          sLineWhere = sLineWhere & CheckSpace(sField) & " = " & sDelimiterPrefix & RecordSet(sField) & sDelimiterSuffix
       end if
       g_LineIndex=Mid(g_LineIndex,iRightB+1,Len(g_LineIn dex))
       iLeftB=InStr(g_LineIndex,"[")
       iRightB=InStr(g_LineIndex,"]")
     wend
   end if

  ProcessViewMode = Err.Number
  if (Err.Number<>0) then
     response.end
  end if

end function

sub NoMatchingDataWarning(g_TextBoxHighlightColor,g_No MatchingData,g_SearchPage,g_SearchAgain)
  response.write "<br><br><center><table width=""80%"" border=""1"" bgColor=""#9596AC"" cellpadding=""5""><tr><td bgColor=""#" & g_TextBoxHighlightColor & """>"
  response.write "<div class=""fieldPrompt""><center>" & g_NoMatchingData & "</center></div>"
  response.write "</td></tr></table><br><br>"
  response.write "<input type=""button"" class=""buttonColor"" title="""" id=""Button"" name=""btnSearch"" onClick=""self.location='" & g_SearchPage & "';"" value=""" & g_SearchAgain & """>"
end sub

sub BuildfrmMain(g_bInWindow,g_TableName,g_ScriptName, g_sMode,g_WhereClause,g_SearchSQL)
  response.write "<iframe id=""_hiddenWindow"" name=""_hiddenWindow"" style=""border: none; width: 0px; height: 0px;""></iframe>"
  response.write "<form method=""POST"" name=""frmMain"" id=""frmMain"" enctype=""multipart/form-data"" action=""" & g_ScriptName & """ target=""_self"">"
  response.write "<input type=""hidden"" name=""InWindow"" value=""" & g_bInWindow & """>"
  response.write "<input type=""hidden"" name=""table500"" value=""" & g_TableName & """>"
  response.write "<input type=""hidden"" name=""formname500"" value=""" & g_ScriptName & """>"
  if (g_sMode="") then
     response.write "<input type=""hidden"" name=""addoramend500"" value=""add"">"
  else
     response.write "<input type=""hidden"" name=""addoramend500"" value=""" & g_sMode & """>"
  end if
  response.write "<input type=""hidden"" id=""currentError"" name=""currentError"" value="""">"
  response.write "<input type=""hidden"" id=""f105where"" name=""f105where"" value=""" & ESCAPETEXTQT(g_WhereClause) & """>"
  response.write "<input type=""hidden"" name=""sSearchSQL"" value=""" & g_SearchSQL & """>"
  for each item in Uploader.mcolFormElem
     if Mid(item,1,7)="Srch571" then
         response.write "<input type=""hidden"" name=""" & item & """ value=""" & Uploader.Form(item) & """>"
     end if
  next
end sub

sub ShowNavigator(bAddfrmLaunch,bReportMode,g_ScriptNa me,g_bInWindow,sRSSQL,iPage,g_FirstRecord,g_PrevRe cord,g_NextRecord,g_LastRecord,g_SearchPage,g_Sear chAgain,g_Add,g_AddRecord,g_LinkField,g_EditOwnRec ords,g_Edit,g_Delete,g_EditRecord,g_DeleteRecord,s LineWhere,iTotalPages)
  Dim iPos

  if (bReportMode) then
     response.write "<form name=""frmNextPrev"" method=""post"" enctype=""multipart/form-data"" action=""" & g_ScriptName & """>"
     response.write "<input type=""hidden"" name=""InWindow"" value=""" & g_bInWindow & """>"
     response.write "<input type=""hidden"" name=""SQL"" value=""" & ESCAPETEXTQT(sRSSQL) & """>"
     response.write "<input type=""hidden"" name=""Page"" value=""" & iPage & """>"
     response.write "<input type=""hidden"" name=""LineIDIndex507"" value=""" & ESCAPETEXT(Request.QueryString("LineIDIndex507")) & ESCAPETEXT(Uploader.Form("LineIDIndex507")) & """>"
     response.write "<input type=""hidden"" name=""frmname500"" value=""" & Uploader.Form("frmname500") & Request.QueryString("frmname500")& """>"

     response.write "<table width=""92%"" cellpadding=""0"" cellspacing=""0"" border=""4""><tr><td>"
     response.write "<table width=""100%"" cellpadding=""2"" cellspacing=""0"" border=""3"">"
     response.write "<tr class=""gridBack""><td width=""1""><center>"
     if iPage<>1 then
        response.write "<input type=""submit"" class=""buttonColor"" id=""button1"" name=""btnPage"" value=""" & g_FirstRecord & """>"
     else
        response.write "&nbsp;"
     end if
     response.write "</center></td><td width=""1""><center>"
     if iPage<>1 then
        response.write "<input type=""submit"" class=""buttonColor"" id=""button2"" name=""btnPage"" value=""" & g_PrevRecord & """>"
     else
        response.write "&nbsp;"
     end if
     response.write "</center></td><td width=""1""><center>&nbsp;</center></td>"

     iPos=cLNG(iPage+1)
     iTotalPages=cLNG(iTotalPages)

     response.write "<td width=""1""><center>"
     if iPage<>iTotalPages then
        response.write "<input type=""submit"" class=""buttonColor"" id=""button3"" name=""btnPage"" value=""" & g_NextRecord & """>"
     else
        response.write "<input type=""submit"" class=""buttonHidden"">"
     end if
     response.write "</center></td><td width=""1""><center>"
     if iPage<>iTotalPages then
        response.write "<input type=""submit"" class=""buttonColor"" id=""button4"" name=""btnPage"" value=""" & g_LastRecord & """>"
     else
        response.write "<input type=""submit"" class=""buttonHidden"">"
     end if
     response.write "</center></td></tr><tr class=""gridBack"">"
     response.write "<td width=""1""><center><input type=""button"" class=""buttonColor"" id=""Button5"" name=""btnSearch"" onClick=""self.location='" & g_SearchPage & "';"" value=""" & g_SearchAgain & """></center></td><td width=""1""><center>"

     if (g_Add>0) then
         response.write "<input type=""button"" class=""buttonColor"" id=""Button6"" name=""btnAddRec"" onClick=""editDeleteRecord2('a');"" value=""" & g_AddRecord & """>"
     else
         response.write "<input type=""submit"" class=""buttonHidden"">"
     end if
     response.write "</center></td><td><div class=""headingRow"">Record " & iPage & " of " & iTotalPages & "</div></td><td width=""1""><center>"
     if (g_LinkField<>"") and (g_EditOwnRecords<>0) and (g_Edit<>0) then
        if (RecordSet(g_LinkField) <> Session("UserID")) then
           g_Edit=0
        end if
     end if

     if (g_Edit>0) then
        response.write "<input type=""button"" class=""buttonColor"" id=""Button7"" name=""btnEdit"" onClick=""editDeleteRecord2('e');"" value=""" & g_EditRecord & """>"
     else
        response.write "<input type=""submit"" class=""buttonHidden"">"
     end if
     response.write "</center></td><td width=""1""><center>"

     if (g_Delete>0) then
        response.write "<input type=""button"" class=""buttonColor"" id=""Button8"" name=""btnDelete"" onClick=""editDeleteRecord2('d');"" value=""" & g_DeleteRecord & """>"
     else
        response.write "<input type=""submit"" class=""buttonHidden"">"
     end if
     response.write "</center></td></tr></table></td></tr></table></form>"

     if (bAddfrmLaunch) then
        response.write "<form enctype=""multipart/form-data"" action=""" & g_ScriptName & """ method=""post"" id=""frmLaunch"" name=""frmLaunch"" target=""editWindow"">"
        response.write "<input type=""hidden"" name=""InWindow"" value=""1"">"
        response.write "<input type=""hidden"" id=""mode"" name=""mode"" value=""edit"">"
        response.write "<input type=""hidden"" id=""f105where"" name=""f105where"" value=""" & ESCAPETEXT(sLineWhere) & """>"
        response.write "</form>"
     end if

  end if
end sub

sub MainDataFormFooter(bReportMode,g_ScriptName,g_bInW indow,sRSSQL,iPage,g_FirstRecord,g_PrevRecord,g_Ne xtRecord,g_LastRecord,g_SearchPage,g_SearchAgain,g _Add,g_AddRecord,g_LinkField,g_EditOwnRecords,g_Ed it,g_Delete,g_EditRecord,g_DeleteRecord,sLineWhere ,iTotalPages,bAllReadOnly,bReadOnly,g_sMode,g_Canc el,g_Save,g_CloseWindow,iMode)

  if (iMode>=0) and (not(bReportMode)) then
     if not(bAllReadOnly) and not(bReadOnly) then
        if (g_sMode="edit") then
            if (g_bInWindow="1") then
               response.write "<input type=""button"" class=""buttonColor"" id=""Button"" name=""btnCancel"" onClick=""window.close();"" value=""" & g_Cancel & """>&nbsp;&nbsp;&nbsp;&nbsp;"
            end if
        end if
        response.write "<input type=""button"" class=""buttonColor"" id=""Button"" name=""btnSave"" onClick=""doSubmit(document.frmMain);"" value=""" & g_Save & """>"
     else
        if (g_bInWindow="1") then
           response.write "<input type=""button"" class=""buttonColor"" id=""Button"" name=""btnCancel"" onClick=""window.close();"" value=""" & g_CloseWindow & """>"
        end if
     end if
  end if
  response.write "</form>" 'Close frmMain
  ShowNavigator True,bReportMode,g_ScriptName,g_bInWindow,sRSSQL,i Page,g_FirstRecord,g_PrevRecord,g_NextRecord,g_Las tRecord,g_SearchPage,g_SearchAgain,g_Add,g_AddReco rd,g_LinkField,g_EditOwnRecords,g_Edit,g_Delete,g_ EditRecord,g_DeleteRecord,sLineWhere,iTotalPages
  if (iMode<0) then
     ' Save Changes Mode
     RecordSet.Update
     response.write "<script language=""JavaScript"">if (window.opener && !opener.closed && window.opener.document.frmRefresh) {window.opener.document.frmRefresh.submit();self.f ocus();}</script>"
     response.write "<center><table width=""80%"" border=""1"" bgColor=""#000000"" cellpadding=""5""><tr><td bgColor=""#FFFFFF"">"
     iError = Err.Number
     if (iError<>0) then
        if (InStr(UCase(Err.Description),"IUSR")>0) or (InStr(UCase(Err.Description),"DATABASE REQUESTED IN LOGIN")>0) or (InStr(UCase(Err.Description),"UPDATEABLE")>0) or (InStr(UCase(Err.Description),"AGGIORNABILE")>0) then
           response.write "<br><br>"
           response.write "Unable to write to database: It is either Read Only or IUSR account does not have sufficient permissions. <br><br>"
           else
           response.write "<div class=""fieldPrompt""><center>" & g_SaveError & ": <br><br>" & Err.Description & "</center></div>"
        end if
     else
        if (iMode=-1) then
           response.write "<div class=""fieldPrompt""><center>" & g_OK1 & "</center></div>"
        else
           response.write "<div class=""fieldPrompt""><center>" & g_OK2 & "</center></div>"
        end if
     end if
     response.write "</td></tr></table><br><br></center>"

     if (iMode=-2) then
        if (iError<>0) then
          response.write "<center><input type=""button"" class=""buttonColor"" title="""" id=""Button"" name=""btnBack"" onClick=""history.go(-1);"" value=""" & g_TryAgain & """></center>"
        else
          if (Uploader.Form("InWindow")="1") then
             response.write "<center><input type=""button"" class=""bigbuttonColor"" title="""" id=""Button"" name=""btnReturn"" onClick=""window.close();"" value=""" & g_CloseWindow & """></center>"
          end if
        end if
     else
        if (iError<>0) then
           response.write "<center><input type=""button"" class=""buttonColor"" title="""" id=""Button"" name=""btnBack"" onClick=""history.go(-1);"" value=""" & g_TryAgain & """></center>"
        else
           response.write "<form name=""frmAnother"" id=""frmAnother"" method=""post"" enctype=""multipart/form-data"" action=""" & g_ScriptName & """><input type=""hidden"" id=""mode"" name=""mode"" value=""add""><input type=""hidden"" name=""InWindow"" value=""" & g_bInWindow & """></form>"
           response.write "<center><input type=""button"" class=""buttonColor"" title="""" id=""Button"" name=""btnAdd"" onClick=""var frmMain=document.getElementById('frmAnother');frmA nother.submit();"" value=""" & g_AddAnother & """></center>"
        end if
    end if
  end if

end sub

function SetupDataForm(g_ScriptName,g_sMode,Conn,RecordSet, g_LinkField,g_EditOwnRecords,bReportMode,bReadOnly ,sSQL,sRSSQL,g_TableName,g_WhereClause,g_CursorLoc ation,g_TextBoxHighlightColor,g_NoMatchingData,g_S earchPage,g_SearchAgain,iTotalPages,g_NextRecord,g _PrevRecord,g_FirstRecord,g_LastRecord,g_LineIndex ,sLineWhere,g_bInWindow,g_PageSubtitle,g_HasDetail Form,iMode,g_SearchSQL,g_Status1,g_Status2,g_Close Window)
   Dim iResult
   Dim sAppVariable1
   Dim sAppVariable2
   Dim iDiff
   Dim strName
   Dim i
   Dim j

   iResult=0

   if (0=1) then
      ' If Edit or Delete mode then check record locking ...
      if (iMode<>0) then
         ' Clear Expired Variables...

         if (ScriptEngineMajorVersion()>=3) then
            j=Application.Contents.Count
            For Each strName in Application.Contents
              if (Mid(strName,1,2)="T|") then
                 iDiff = DateDiff("n",Application(strName),now())
                 if (iDiff>20) then
                    'expired variable
                    Application.Contents.Remove Mid(strName,2)
                    Application.Contents.Remove strName
                 end if
              end if
            Next
         end if

         sAppVariable1 = g_ScriptName & "|" & g_WhereClause
         sAppVariable2 = "T|" & g_ScriptName & "|" & g_WhereClause
         if (Application(sAppVariable1)="") then
            ' Not already locked, so lock it.
             Application(sAppVariable1)=Session("fldUsername01" )
             Application(sAppVariable2)=Now()
         else
            ' Already locked, so see who it is...
            iDiff= DateDiff("n",Application(sAppVariable2),Now())
            if (Application(sAppVariable1)=Session("fldUsername01 ")) OR (iDiff>=20) then
               ' Same user or timed out so renew lock.
                Application(sAppVariable2)=Now()
            else
                response.write "<div align=""center""><center><table width=100% height=""100%""><tr><td valign=""middle"" align=""center"">"
                response.write "<table border=""0"" cellpadding=""5"" cellspacing=""0"" bgColor=""#EDEDED""><tr><td><div align=""center"">"
                response.write "<table border=""1"" cellpadding=""5"" cellspacing=""0"" bordercolorlight=""#000000"" bordercolordark=""#FFFFFF"">"
                response.write "<tr><td><div align=""center""><table border=""0"" cellpadding=""5"" cellspacing=""0"">"
                response.write "<tr><td class=""mainTitle"">Record Locked by user [" & Application(sAppVariable1) & "] for " & iDiff+1 & " minute(s)</td></tr>"
                response.write "<tr><td class=""fieldPrompt""><center>Please try again later</center></td></tr>"
                response.write "<tr><td><center><input type=""button"" class=""bigbuttonColor"" id=""Button8"" name=""btnReturn"" onClick=""window.close();"" value=""" & g_CloseWindow & """></center></td></tr>"
                response.write "</table></div></td></tr></center></table></div></td></tr></table></td></tr></table></div>"
                response.end
            end if
         end if
      end if
   end if

   CreateDataPageSubForms g_ScriptName,g_sMode,g_HasDetailForm
   if (g_sMode="delete") then
      iResult = iResult + DeleteSelectedRecord(Conn,g_TableName,g_WhereClaus e,g_Status1,g_Status2,g_CloseWindow)
   elseif (g_sMode="edit") then
      iResult = iResult + EditSelectedRecord (g_ScriptName,g_sMode,Conn,RecordSet,g_LinkField,g _EditOwnRecords,bReportMode,bReadOnly,sSQL,sRSSQL, g_TableName,g_WhereClause,g_CursorLocation,g_TextB oxHighlightColor,g_NoMatchingData,g_SearchPage,g_S earchAgain,iTotalPages,g_NextRecord,g_PrevRecord,g _FirstRecord,g_LastRecord,g_LineIndex,sLineWhere,i Mode)
   end if

   iResult = iResult + ProcessViewMode (g_ScriptName,g_sMode,Conn,RecordSet,g_LinkField,g _EditOwnRecords,bReportMode,bReadOnly,sSQL,sRSSQL, g_TableName,g_WhereClause,g_CursorLocation,g_TextB oxHighlightColor,g_NoMatchingData,g_SearchPage,g_S earchAgain,iTotalPages,g_NextRecord,g_PrevRecord,g _FirstRecord,g_LastRecord,g_LineIndex,sLineWhere,i Mode)

   g_PageSubtitle = ""
   if (iMode=-1) then
       g_PageSubtitle = "Save New Record"
   elseif (iMode=-2) then
       g_PageSubtitle = "Save Updated Record"
   elseif (bReportMode) or (bReadOnly) then
      g_PageSubtitle = "View Record"
   elseif (g_sMode="delete") then
      g_PageSubtitle = "Delete Record"
   elseif (g_sMode="edit") then
      g_PageSubtitle = "Edit Record"
   else
      g_PageSubtitle = "Add Record"
   end if

   g_PageSubtitle = g_PageSubtitle & " -> " & g_TableAlias & "&nbsp;"

   BuildfrmMain g_bInWindow,g_TableName,g_ScriptName,g_sMode,g_Whe reClause,g_SearchSQL

   if (iMode = -1) then
      Set RecordSet = Server.CreateObject("ADODB.Recordset")
      RecordSet.Open "SELECT * FROM " & g_TableName, Conn, 2, 2
      RecordSet.AddNew
   elseif (iMode = -2) then
      Set RecordSet = Server.CreateObject("ADODB.Recordset")
      RecordSet.Open "SELECT * FROM " & CheckSpace(Uploader.Form("table500")) & " WHERE " & ESCAPESQL(Uploader.Form("f105where")), Conn, 2, 2

      if (0=1) then
         ' Clear any Locks...
         if (ScriptEngineMajorVersion()>=3) then
            Application.Contents.Remove sAppVariable1
            Application.Contents.Remove sAppVariable2
         else
            Application(sAppVariable1)=Null
            Application(sAppVariable2)=Null
         end if
      end if
   end if

   SetupDataForm = iResult
end function


'/////////////////// Search Page Functions

sub GenerateSearchPageFooter()
  response.write "</form>"
  response.write "<form name=""frmFindRecord"" id=""frmFindRecord"" enctype=""multipart/form-data"" method=""post"" target=""_searchWindow"">"
  response.write "<input type=""hidden"" name=""Lookup"" value=""1"">"
  response.write "<input type=""hidden"" name=""InWindow"" value=""1"">"
  response.write "<input type=""hidden"" name=""refFieldName"" value="""">"
  response.write "<input type=""hidden"" name=""refReturnFieldCode"" value="""">"
  response.write "<input type=""hidden"" name=""refReturnFieldDesc"" value="""">"
  response.write "<input type=""hidden"" name=""refUpdateField"" value="""">"
  response.write "<input type=""hidden"" name=""refField"" value="""">"
  response.write "<input type=""hidden"" name=""refTable"" value="""">"
  response.write "<input type=""hidden"" name=""refCodeValue"" value="""">"
  response.write "<input type=""hidden"" name=""refDescValue"" value="""">"
  response.write "<input type=""hidden"" name=""refDataType"" value="""">"
  response.write "</form>"

  if (Request.QueryString("list")="auto") then
     response.write "<script language=""JavaScript"">"
     response.write " document.frmMain.submit();"
     response.write "</script>"
  end if

end sub

sub SetupSearchForm(g_bInWindow,g_TableName,iForm,g_Li neIndex,g_TableAlias)
  if (g_bInWindow<>"1") then
     response.write ""
  end if

  response.write "<table width=""100%""><tr><td class=""rightTitle"">"
  if Uploader.Form("Lookup")<>"1" then
     response.write "Search Data"
  else
     response.write "Lookup Data"
  end if
  response.write " -> " & g_TableAlias & "&nbsp;</td></tr></table>"

  response.write "<iframe id=""_hiddenWindow"" name=""_hiddenWindow"" style=""border: none; width: 0px; height: 0px;""></iframe>"
  response.write "<form method=""POST"" name=""frmMain"" id=""frmMain"" enctype=""multipart/form-data"" action=""searchdata.asp"" target=""_self"">"
  response.write "<input type=""hidden"" name=""InWindow"" value=""" & g_bInWindow & """>"
  response.write "<input type=""hidden"" name=""table500"" value=""" & g_TableName & """>"
  response.write "<input type=""hidden"" name=""frmname500"" value=""" & iForm & """>"
  response.write "<input type=""hidden"" name=""LineIDIndex507"" value=""" & g_LineIndex & """>"
  response.write "<input type=""hidden"" name=""currentError"" value="""">"
  response.write "<input type=""hidden"" name=""DisplayName"" value=""" & g_TableAlias & """>"
  response.write "<input type=""hidden"" name=""Lookup"" value=""" & Uploader.Form("Lookup") & """>"
  response.write "<input type=""hidden"" name=""refFieldName"" value=""" & ESCAPETEXT(Uploader.Form("refFieldName")) & """>"
  response.write "<input type=""hidden"" name=""refReturnFieldCode"" value=""" & ESCAPETEXT(Uploader.Form("refReturnFieldCode")) & """>"
  response.write "<input type=""hidden"" name=""refReturnFieldDesc"" value=""" & ESCAPETEXT(Uploader.Form("refReturnFieldDesc")) & """>"
  response.write "<input type=""hidden"" name=""refUpdateField"" value=""" & ESCAPETEXT(Uploader.Form("refUpdateField")) & """>"

end sub

sub GenerateSearchPageButtons(sSearch,g_iSecurityLevel ,iCSV,sCSV,sReport)
  response.write "<br><input type=""submit"" value=""" & sSearch & """ class=""buttonColor"" id=""Button"" name=""btnSearch"" onClick=""printList(0);""><br><br>"
  if Uploader.Form("Lookup")<>"1" then
     if ((g_iSecurityLevel) and (iCSV)) then
        response.write "<input type=""submit"" value=""" & sCSV & """ class=""buttonColor"" id=""Button3"" name=""btnSearch"" onClick=""printList(0);""><br><br>"
     end if
     response.write "<input type=""submit"" value=""" & sReport & """ class=""buttonColor"" id=""Button2"" name=""btnSearch"" onClick=""printList(0);""><br><br>"
     response.write "<input type=""submit"" value=""" & "Print" & """ class=""buttonColor"" id=""Button4"" name=""btnSearch"" onClick=""printList(1);""><br><br>"
  end if
end sub


'/////////////////// Search Data Functions


function SizeColumn (sData)
   If IsNull(sData) then
      sData=" "
   else
      iLen=Len(sData)
      sData=Mid(CStr(sData),1,25)
      if (iLen>25) then
         sData=sData+"..."
      end if
      if (sData="") then
         sData=" "
      end if
      SizeColumn=sData
   end if
end function

function PadData (sData,iLen)
    while (Len(sData)<iLen)
        sData="0"+CStr(sData)
    Wend
    PadData=sData
end function

function ProcessTheDate(sValue)
  Dim sDate,sTime,iFormat
  sDate=""
  sTime=""
  iDF=0
  iDBDF=0
  if (sValue="") then
     ProcessTheDate="Null"
     exit function
  end if
  if (Len(sValue)>=8) then
     if (iDF=0) then
       sMonth = Mid(CHECKNULL(sValue),1,2)
       sDay = Mid(CHECKNULL(sValue),3,2)
       sYear = Mid(CHECKNULL(sValue),5,4)
     elseif (iDF=1) then
       sDay = Mid(CHECKNULL(sValue),1,2)
       sMonth = Mid(CHECKNULL(sValue),3,2)
       sYear = Mid(CHECKNULL(sValue),5,4)
     elseif (iDF=2) then
       sYear = Mid(CHECKNULL(sValue),1,4)
       sMonth = Mid(CHECKNULL(sValue),5,2)
       sDay = Mid(CHECKNULL(sValue),7,2)
     end if
     if (iDBDF=0) then
       sDate=sMonth & "/" & sDay & "/" & sYear
     elseif (iDBDF=1) then
       sDate=sDay & "/" & sMonth & "/" & sYear
     elseif (iDBDF=2) then
       sDate=sYear & "/" & sMonth & "/" & sDay
     end if
  end if
  if (Len(sValue)=12) then
     sTime=Mid(CHECKNULL(sValue),9,2) & ":" & Mid(CHECKNULL(sValue),11,2)
  elseif (Len(sValue)=4) then
     sTime=Mid(CHECKNULL(sValue),1,2) & ":" & Mid(CHECKNULL(sValue),3,2)
  end if
  sDelimiterPrefix="'"
  if (sDelimiterPrefix="'") then
    sDelimiterPrefix="[039SGLQUOT]"
  end if
  sDelimiterSuffix="'"
  if (sDelimiterSuffix="'") then
    sDelimiterSuffix="[039SGLQUOT]"
  end if
  sTemp=sDelimiterPrefix
  sTemp=sTemp & sDate & " " & sTime
  sTemp=Trim(sTemp) & sDelimiterSuffix
  if Trim(sDate )="" and Trim(sTime)="" then
     sTemp="NULL"
  end if
  ProcessTheDate=sTemp
end function

function GetTheDate(sDate,iType,sSeperator,sTSeperator1,sTS eperator2)
  Dim dd,mm,yyyy,hh,nn, iFormat
  iFormat = 0
  if (sDate<>"NOW") then
     if (IsNull(RecordSet(sDate))) then
        GetTheDate=""
        exit function
     end if
     dd = cStr(Day(RecordSet(sDate)))
     mm = cStr(Month(RecordSet(sDate)))
     yyyy = cStr(Year(RecordSet(sDate)))
     hh = CStr(Hour(RecordSet(sDate)))
     nn = CStr(Minute(RecordSet(sDate)))
  else
     dd = cStr(Day(Now()))
     mm = cStr(Month(Now()))
     yyyy = cStr(Year(Now()))
     hh = CStr(Hour(Now()))
     nn = CStr(Minute(Now()))
  end if
  if Len(dd)=1 then
     dd="0" & dd
  end if
  if Len(mm)=1 then
     mm="0" & mm
  end if
  if Len(hh)=1 then
     hh="0" & hh
  end if
  if Len(nn)=1 then
     nn="0" & nn
  end if
  if (iFormat=0) then
     if (iType=0) then
        GetTheDate="" + mm + sSeperator + dd + sSeperator + yyyy
     elseif (iType=1) then
        GetTheDate="" + hh + sTSeperator2 + nn
     elseif (iType=2) then
        GetTheDate="" + mm + sSeperator + dd + sSeperator + yyyy + sTSeperator1 + hh + sTSeperator2 + nn
     end if
  elseif (iFormat=1) then
     if (iType=0) then
        GetTheDate="" + dd + sSeperator + mm + sSeperator + yyyy
     elseif (iType=1) then
        GetTheDate="" + hh + sTSeperator2 + nn
     elseif (iType=2) then
        GetTheDate="" + dd + sSeperator + mm + sSeperator + yyyy + sTSeperator1 + hh + sTSeperator2 + nn
     end if
  elseif (iFormat=2) then
     if (iType=0) then
        GetTheDate="" + yyyy + sSeperator + mm + sSeperator + dd
     elseif (iType=1) then
        GetTheDate="" + hh + sTSeperator2 + nn
     elseif (iType=2) then
        GetTheDate="" + yyyy + sSeperator + mm + sSeperator + dd + sTSeperator1 + hh + sTSeperator2 + nn
     end if
  end if
end function

function ProcessWHEREField(item,sOverride,sWHERE,sORDERBY,b First,bFirstOrderBy)
   Dim sNumber,sNumber2
   iType=Uploader.form("type" & item)
   sField=Uploader.form("db" & item)

   ' Find out which option was selected ...
   iAction=Uploader.form("z"+item)

   if (iAction>0) then

      bWhere=1
      if (bFirst=0) then
         if (sOverride="") then
            sWHERE=sWHERE & " AND "
         else
            sWHERE=sWHERE & ") OR ("
         end if
      else
         bFirst=0
      end if

      if (sOverride="") then
         if (bFirstOrderBy=0) then
            if (Uploader.form("SndOrderBy127")="") then
               sORDERBY=sORDERBY & " , "
            end if
         else
            bFirstOrderBy=0
         end if
      end if

      if (sOverride="") then
         if (iType>=3) and (iType<=9) AND (ProcessTheDate(Uploader.form(item))="Null") then 'Date / Time / Date/Time
            if ("'"="#") then 'Access
               sWHERE=sWHERE & CheckSpace(sField)
            elseif ("'"="'") then 'SQL Server
               sWHERE=sWHERE & "IsNull(" & CheckSpace(sField) & ",[039SGLQUOT][039SGLQUOT])"
            else 'Other
               sWHERE=sWHERE & CheckSpace(sField)
            end if
         else
            sWHERE=sWHERE & CheckSpace(sField)
         end if
      else
         sWHERE=sWHERE & CheckSpace(sOverride)
      end if
      if (sOverride="") then
         if (Uploader.form("SndOrderBy127")="") and (InStr(sField,sORDERBY)=









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.